AS3 add movie clip to stage using variable which holds the MC name

I know how to add a movie clip to the stage from the library but i'm strugling to do it when the I need to load a movie clip from the library when the name of the movie clip is held in a variable.

for(var i:Number = 0; i < 64; i++)
{
    var blueIconS:blueIcon = new blueIcon();
    addChild(blueIconS);
    blueIconS.x = 100;
    blueIconS.y = 100;
}

The above code works for adding the blueIcon but I have a variable in that loop which tells which icon to load.

sectorsMCs[jewelsIDs[i]]

The above will tell me what MC name to load but how do I load a MC from library by that variable value?

Answers


You may have to link your MovieClip to a specific class for the following to work...

 var mcName:String = sectorsMCs[jewelsIDs[i]];
 var ClassName:Object = getDefinitionByName(mcName);
 var mc:MovieClip = new ClassName();

Need Your Help

notification in iphone and android using as3

android iphone actionscript-3 air air-native-extension

I need to show notifications at specific time through the app(iphone and android app). The app is developed fully in as3.

Add Checkbox to datatables JQuery service side

javascript jquery checkbox datatables

I'm server side I want to add a checkbox who returns true or false when the checkbox is checked or not. But I don't know how to add the event on change to my checkbox in the table and send the Bool...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.