If it works without it, it is not required.
Import is a compiler directive.
It does not result in any code being generated.
It merely tells the compiler that "If I mention some function or
class/object/datatype that I do not define, you should also look here to
see if this code has a definition."
If the compiler is already adding the library automatically to the list
of places that it looks for things, you do not need it.
For example, the Flash IDE knows about "MovieClip" and will find any
method or property that deals with a MovieClip object without being told
where MovieClip is defined.
It looks like Sprite is also in the list of things that it knows.
If you add the import but never reference anything from it, it will not
have any effect on your resulting swf file.
It is a "shortcut" in the sense that if you did not have the import, you
would have to write the full name with
flash.display.Sprite.xxx every time that you referred to a method or
property of a Sprite.
I am not even sure of the syntax since no one in their right mind would
trade an "import" statement for all that typing and it NEVER appears in
any code examples that I have seen.
I hope that this helps
Ron
[EMAIL PROTECTED] wrote:
I'm just now trying to wrap my head around AS3.0, so this is a very
basic question. Why is the import statements necessary? The Adobe
site says that in AS2.0 it was a shortcut, so you didn't have to
type the full path, but in AS3.0 it is a requirement.
So why does the following simple code work with and without the
import statements? If I don't create my own classes in an external
.as file because I just want to use Flash's predefined classes, do
I have to use the import statement?
import flash.display.Sprite;
//is the import necessary? works with or without it.
//
// draw a circle and add it to the display list
var circle:Sprite = new Sprite();
circle.graphics.beginFill(0x990000);
circle.graphics.drawCircle(50, 50, 50);
circle.graphics.endFill();
addChild(circle);
_______________________________________________
[email protected]
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
_______________________________________________
[email protected]
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