I think Ian stated that Importing a class will not affect the swf, but instanciating an object contained in the class will.

So:

import MyCoolNewClass;

does not affect swf

var MyCoolNewClass:MyCoolNewClass = new MyCoolNewClass();

does affect swf



Merrill, Jason wrote:
The 'import' statement doesn't actually embed a class into the .swf.
All it does is tell the compiler that when you type (for example)
MyClass, you are actually referring to com.fred.MyClass.

Err...that has not been my understanding at all.  If that is the case,
then why do you NOT need to include your class files on the server with
the .swf?  Since reality is you don't, all that code has to be in the
.swf upon compiling, otherwise, the .swf wouldn't know what to do with
Myvar:MyCoolClass = new MyCoolClass();

If it's not included with the .swf, how would the .swf know what
MyCoolClass is otherwise?


Jason Merrill
Bank of America Learning Technology Solutions
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:flashcoders-
[EMAIL PROTECTED] On Behalf Of Ian Thomas
Sent: Thursday, May 25, 2006 12:27 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] OOP 101: Is import really necessary?

Errm - actually that's not such a good reason.

The 'import' statement doesn't actually embed a class into the .swf.
All it does is tell the compiler that when you type (for example)
MyClass, you are actually referring to com.fred.MyClass.

You could just type com.fred.MyClass throughout the body of your code
instead of typing import at the top of the file.

'import' is simply a disambiguation helper for the compiler. It's got
nothing to do with what code actually gets included in the resultant
.swf. You can prove this by typing:
import com.fred.*   // Replace with some set of classes you're not
using in your current project

And recompiling. The .swf file size won't go up until you actually
_reference_ an object that belongs to one of those packages. As soon
as you typed:
var f:MyClass=new MyClass();

or, in fact
var f:com.fred.MyClass=new com.fred.MyClass();

The file size would go up.

So - in answer to RifledCloaca - no, you don't need to type 'import'
at all, as long as you refer to all your classes by full packagename.

Ian

On 5/25/06, Merrill, Jason <[EMAIL PROTECTED]> wrote:
Because if Flash imported every class available to it automatically,
then your .swf files would be huge and unnecessarily bloated.  Do
you
really want the code to all the Remoting classes imported into your
.swf
if you're not using them? When you include, the actionscript
cotained in
the class is embedded in the .swf.

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to