import in flash is only used to save you some typing.

when you use

import com.package.Class;

the class is *not* included in the swf until you reference that class in your code somewhere.

like

var blah:Class;

you don't have to use import, you can also use:

var blah:com.package.Class;

and it will behave exactly the same way, only every time you reference the class, you'll need to type the full path instead of just 'Class'

it's just a typing shortcut.



On May 25, 2006, at 2:01 PM, j.c.wichman wrote:

Hi,
it is included, but not solely becoz of the import statement.
I might be wrong, but I believe this is even a 'bug'.

Expected behavior:
import MyClass causes inclusion of MyClass in the swf

Real behavior:
import MyClass still requires you to use MyClass somewhere in the code as in
var myClass:MyClass, in order for it to be included.

Note that we are talking about the Flash IDE here, with mtasc you can
include exclude any class you like whether or not it is referenced in the
code.

greetz
Hans

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of Merrill, Jason
Sent: Thursday, May 25, 2006 7:25 PM
To: Flashcoders mailing list
Subject: RE: [Flashcoders] OOP 101: Is import really necessary?

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

_______________________________________________
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