Benoît Freslon
Benoît Freslon

Reputation: 2021

ActionScript - Get the names of the elements in the library or the names of "the link to AS3"

I would like to get the name of the elements in the library when this element is on the stage. If I can't I would like to get the name of "The AS3 link".

enter image description here

I tried with this code:

for (var i=0; i<this.numChildren; i++){
    trace("Movie Name: "+this.getChildAt(i).name);
    trace("Movie Class: "+getQualifiedClassName(this.getChildAt(i)));
    trace("Movie Super Class: "+getQualifiedSuperclassName(this.getChildAt(i)));
}

But I only get this: Movie Name: instance1 Movie Class: flash.display::Bitmap Movie Class: flash.display::DisplayObject

Upvotes: 0

Views: 764

Answers (2)

Harrison
Harrison

Reputation: 305

It is impossible to get the name from library. It is used only by the Flash IDE and it is not exported.

To get the class name from a bitmap in stage, you can try this:

var bitmapData:BitmapData = Bitmap(getChildAt(0)).bitmapData;
trace(getQualifiedClassName(bitmapData))

Upvotes: 1

Daniil Subbotin
Daniil Subbotin

Reputation: 6708

In you library there are three images. Linkage name of the image represents a BitmapData class. You can't add BitmapData directly to the stage. Firstly, you create a BitmapData instance:

var bitmapData:BitmapData = new SomeBitmapData();

SomeBitmapData it's a linkage name of the image.

enter image description here

Then you add an instance of Bitmap class:

var bitmap:Bitmap = new Bitmap(bitmapData);
addChild(bitmap);

If you want to get linkage name e.g. SomeBitmapData you should write:

trace(getQualifiedClassName(bitmapData)); // SomeBitmapData

Upvotes: 0

Related Questions