开发者

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?


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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜