1

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?

Scott
  • 3,967
  • 9
  • 38
  • 56

1 Answers1

1

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();
PatrickS
  • 9,539
  • 2
  • 27
  • 31