Yep - just to reiterate (and hopefully make it more clear):

The line:
import com.fred.MyClass;

Is _not enough_ to get Flash to compile MyClass into your .swf file.

You need to actually _reference_ MyClass for it to be included.
e.g. var a:MyClass=new MyClass();

In fact, import is _nothing to do_ with getting Flash to include
compiled code into a .swf.

All import does is to tell the compiler that whenever you refer to a
class by a short name (MyClass) that it doesn't know anything about,
it should check through the list of imports and try and match it up
with one of them; and when it gets a successful match it should use
the full package name and class.

It's kind of "when I _say_ MyClass, I really _mean_ com.fred.MyClass,
but can't be bothered typing it"

That's all. :-)

And that's why import com.fred.*; works. The compiler is just using
that line (when you refer to a class by it's short name later on) to
do a simple pattern match to try to work out what the package name for
the class really is. import com.fred.* doesn't include all the _code_
of com.fred.*. It just means "when I mention a class you haven't heard
of before and can't find, check it against everything under com.fred".
If it _did_ include all the code, your swfs would be bloated beyond
belief.

It's the actual usage of references to the object - declaration,
instantiation, method calling - that makes Flash's equivalent of a
linker include the compiled code for the class into the SWF.

This is demonstrated when you are trying to instantiate classes via
something like ClassFinder
(http://dynamicflash.com/2005/03/class-finder/) and only ever
referring to them using string names rather than actually referring to
them directly in code. You'll find that you _can't_ instantiate the
classes, even if you put in import lines for them - Flash hasn't
worked out you need them in your .swf. So you need to actually put
references to them into the code - normally doing something like:
import com.fred.MyDynamicClass;
var a:MyDynamicClass;

is enough to make sure the linker works it all out and it's included.


Hope that makes it clearer,
 Ian

On 5/25/06, Merrill, Jason <[EMAIL PROTECTED]> wrote:
I see - gotcha.

Jason Merrill
Bank of America
Learning Technology Solutions
_______________________________________________
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