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

import a class: how many ways are there? swc, import, extend, base class

Participant ,
Apr 18, 2013 Apr 18, 2013

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

TOPICS
ActionScript
1.4K
Translate
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

correct answers 1 Correct answer

Guru , Apr 18, 2013 Apr 18, 2013

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.

Translate
Guru ,
Apr 18, 2013 Apr 18, 2013

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.

Translate
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
Participant ,
Apr 18, 2013 Apr 18, 2013

That explains that one cheers.

How about the rest

Translate
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 ,
Apr 19, 2013 Apr 19, 2013

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.

Translate
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
Participant ,
Apr 19, 2013 Apr 19, 2013

Oh dear.

I think I was getting everything totally confused. I was confusing swfs (movie clips) with classes as you say.

Cheers again

Translate
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
Participant ,
Apr 27, 2013 Apr 27, 2013

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

Translate
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 ,
Apr 27, 2013 Apr 27, 2013

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.

Translate
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
Participant ,
Apr 27, 2013 Apr 27, 2013
LATEST

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

Translate
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