• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

import

Guest
Jan 18, 2011 Jan 18, 2011

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?

TOPICS
ActionScript

Views

998

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 18, 2011 Jan 18, 2011

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)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 18, 2011 Jan 18, 2011

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2011 Jan 19, 2011

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 )

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 19, 2011 Jan 19, 2011

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 19, 2011 Jan 19, 2011

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2011 Jan 19, 2011

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 19, 2011 Jan 19, 2011

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)) ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2011 Jan 19, 2011

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 19, 2011 Jan 19, 2011

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..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2011 Jan 19, 2011

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).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2011 Jan 19, 2011

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 19, 2011 Jan 19, 2011

Copy link to clipboard

Copied

LATEST

heys thx for the help

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines