Copy link to clipboard
Copied
Hi all, i was wondering is the flash import statement the same as a java import statement? in other words is it true that if i want to create a transition simply new fl.transitions.Tween(home_mc, "x",fl.transitions.easing.Elastic.easeOut,1000,0,30,true) will work without any import?
Copy link to clipboard
Copied
didn't you see error messages when you tried that code? use:
import fl.transitions.Tween;
import fl.transitions.easing.Elastic;
var t:Tween = new Tween(home_mc, "x", Elastic.easeOut,1000,0,30,true)
Copy link to clipboard
Copied
i mean is the import really necessary if i prefer to qualify the code by its full name.. or is it a compulsory thing to import?
Copy link to clipboard
Copied
You still need to import the class/package even if you use full class name. (According to the doc, this is not the case in AS2, but I can't remember )
Copy link to clipboard
Copied
heys where did you get the docs from? because i find it very weird that we still have to import even after qualifying the class by its full name
Copy link to clipboard
Copied
I am not going to argue although I find it quite efficient and sufficient that whatever datatypes are used in the current scope are available to entire scope. Also, one of the conveniences of imports is that if there is no datatype instantiation (static usage) - class is not included into compiled application although import statement is present.
My question is: conceptually, what would be the benefit of what you are attempting to do?
Copy link to clipboard
Copied
The doc is here:
http://help.adobe.com/en_US/FlashPlatform//reference/actionscript/3/statements.html#import
Personally, I use FlashBuilder and it imports classes automatically so I never actually need to type any "import" directives at all (this applies to other AS3 dev environments too). So this argument is purely academic to me
Copy link to clipboard
Copied
ok guys thx for the help. anyways i've got another question. I have imports statement in the actions of my frame1. and when the user clicks a button i will gotoAndStop(frame1), so my question is that wouldn't that mean that the imports statement are sort of "run again" (i mean i know there's no errors but would it be that the statements are actually read, then ignored, whenever i do gotoAndStop(frame1)) ?
Copy link to clipboard
Copied
The "import" directives does not "run". It tells the compiler where to find the class/functions.
I don't use timelines so I didn't know this, but I just discovered if you import a class in the frame 1 and you want to use that class in the frame 2 you either need to import the class again in the frame 2 or use full class name - in other words if you use full class name you do not need to write import directives in every frame as long as you have them in somewhere just once.
So this explains why you were asking this - or may be not
Copy link to clipboard
Copied
heys, i've no idea why, but i can refer to the classes (like just Tween) in the other frames even when they do not have the import statement.. sounds weird huh
btw i was wondering, what implications may i face if i have this in my code:
import flash.events.MouseEvent;
import flash.events.MouseEvent;
import flash.events.MouseEvent;.. x30
there isn't any compiler errors at all when i tried that..
Copy link to clipboard
Copied
many classes are imported automatically when you code on a timeline so an import statement is not needed.
i'm not sure what you're trying to demonstrate with that code but i would expect you to see a compiler error because that third line of code is problematic. why you fail to see an error is because you're doing something screwy (like not really using that code).
Copy link to clipboard
Copied
btw i was wondering, what implications may i face if i have this in my code:
import flash.events.MouseEvent;
import flash.events.MouseEvent;
import flash.events.MouseEvent;.. x30
there isn't any compiler errors at all when i tried that..
There are no implications apart from being pointless. I am repeating myself but "import" directives are not functions and they do nothing but just tells compiler where to find external classes/functions. As others have mentioned, if you do not actually use MouseEvent in your script, your code above is completely ignored and nothing is imported. In fact if you import bogus Class that doesn't exist, you can still compile and run the SWF because your import statements are just ignored.
Copy link to clipboard
Copied
heys thx for the help