Hi, helmut, only the referenced classed will make it to the swf bytecode.
So, if you have:
import somePackage.ClassA;
import somePackage.ClassB;
private var _objectA:ClassA;
Only the ClassA will be compiled. Of course, if you call the constructor,
it'll be compiled as well. That's a traditional approach followed by
Macromedia/Adobe to keep the swf's as light as possible. Since
somePackage.ClassB is not actually used in your code, it'll be left out. By
referencing it, you can force the compiler to include your class in the
final bytecode
(Not need to bother with that usually, but it helped my to prevent some
aperently really odd bugs with a class compiled into various swf in a rather
large project. Since many swfs holded the bytecode for the same class, the
one in the first swf loaded was the actual code used -- the other
definitions are discarded at runtime. If that swf was compiled with an old
version of the class, then that old code was used by the app, and all the
changes made to tha class would be missed at runtime. If, however, while
navigating the site I happened to load first another swf that was exported
with the new version of the class, I'd see the new behavior. It tripped me
out for a quite a while until I realized what was going on. I fix it by
forcing the main swf to compile the class just referencing it in a var
declaration)
If I'm not mistaken, these are equivalent.
var mySprite:Sprite = new Sprite();
var mySprite:Sprite = new Sprite;
However, if you don't use the parenthesis, you can't pass parameters to the
constructor.
Cheers.
Juan Pablo Califano
----- Original Message -----
From: "Helmut Granda" <[EMAIL PROTECTED]>
To: "Flash Coders List" <flashcoders@chattyfig.figleaf.com>
Sent: Monday, January 14, 2008 8:26 PM
Subject: [Flashcoders] Classes added
I remember reading in a book/article that you can import all the classes
you
need and only the ones used by the application will be actually added....
this thought has been bother me because my logic says... "Import all
classes
since only the ones used will be added it doesnt matter what classes you
import"
For example in the following:
import flash.display.*;
var mySprite:Sprite = new Sprite();
Does that means that only the Sprite class will be added or will all the
classes under display will still be added?
//Another basic question... could some one point me to a resource to
understand the difference between
var mySprite:Sprite = new Sprite;
and
//notice the end ()
var mySprite:Sprite = new Sprite();
I tried to google it but didnt know exactly how to find it..
Thanks for your input...
--
...helmut
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders