Copy link to clipboard
Copied
How many ways are there to import a class and am I getting confused
1. public class Screen extends MovieClip
This inherits all properties and methods of the MovieClip class so WHY do we still use: import flash.display.MovieClip;
Does that import something else or have a just done the job twice
2. import flash.display.MovieClip - so no need to extend (repeating myself again - see 1)
3. swc: connect to an swc
4. embed a swf with a meta tag
5. in properties panel menu - add a Class as the base class
omg - a little confusing
you can only "extend" another class if the compiler knows where it is.
The import statement is solely for the compiler to find the class on your harddrive.
He doesn`t "import" the whole class in the sense you are importing a BMP into Photoshop.
Copy link to clipboard
Copied
you can only "extend" another class if the compiler knows where it is.
The import statement is solely for the compiler to find the class on your harddrive.
He doesn`t "import" the whole class in the sense you are importing a BMP into Photoshop.
Copy link to clipboard
Copied
That explains that one cheers.
How about the rest
Copy link to clipboard
Copied
In addition to what mocca... wrote
import flash.display.MovieClip - so no need to extend (repeating myself again - see 1)
If you write:
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
and don't explicitly state which one of the imported classes your class extends - how would compiler know your intentions? Import statement does not mean your class inherits all API of imported classes. Import statement just says that "if I use any particular datatype - I told you where to find it." Usage of datatype can be instantiating variables, referencing instances with a particular datatype signatures of extending datatypes.
Points 3-5 I guess stem from a confusing two different aspects.
Before you start importing you need to map IDE/compiler to top directories where it can find imported datatypes except for the native AS3 libraries which are mapped for you by default. SWC is just a compiled library (sort of SWF) as opposed to straight directories on your machine.
Copy link to clipboard
Copied
Oh dear.
I think I was getting everything totally confused. I was confusing swfs (movie clips) with classes as you say.
Cheers again
Copy link to clipboard
Copied
Oh dear - sorry to reopen this discussion when I thought it was answered
BUT
package com.Gerry.managers
{
import com.Gerry.db.DbManager;
import com.Gerry.controller.Home;
import com.Gerry.screens.HomeKids1;
public class RevisionManager extends LevelManager
In the first answer it stated that you need not only EXTEND but IMPORT etc...
This class extends LevelManager BUT doesn't import LevelManager.as
therefore the first answer isn't correct.
This is a custom class and the first answer referred to extending the MovisClip which is a built in class in flash. As MovieClip must be "massive" ie: with hundreds of properties perhaps that is the reason you may have to import flash.MovieClip -
just looking for clarification.
Cheers
Copy link to clipboard
Copied
import statement is a map to where class resides in the package - it has no other meaning. If class resides in the same directory as class that uses it - import statement is not necessary.
In you case if both RevisionManager and LevelManager reside in com.Gerry.managers package - there is no need for explicit import. So, technically, the answer is correct.
Importing of class has absolutely nothing to do with class size.
MovieClip is not a massive class - it has only 10 properties and 8 methods in addition to its super classes.
Copy link to clipboard
Copied
I stand corrected yet again. May I see the day that I stand as tall as you in the land of AS3 - I wish.
I forgot about the "being in the same package part".
Cheers and have a great weekend.
Gerry
Find more inspiration, events, and resources on the new Adobe Community
Explore Now