i am trying to pull out a random movieclip from the library and use “addChild” to add it to another movieclip on stage by using an array…
basically, i need to be able to create an array that has all the names of the movieclips i want to randomly pull out… and then randomly select a name from that array so i can use it to get the movieclip out…
i cant seem to be able to tell flash that the name in the array is referring to a movieclip in the library…
which is why the code below returns an error…
// Add Placeholders
var tl_holder:MovieClip;
tl_holder = new HolderClass();
stageholder.addChild(tl_holder);
tl_holder.x = 116
tl_holder.y = 69
// Create Array
var characterArray:Array = ["bear", "cat", "rifle"];
// Count 3 Seconds and then run the "ac_TL" function
var tl_timer:Timer = new Timer(3000, 1);
tl_timer.addEventListener(TimerEvent.TIMER, ac_TL);
tl_timer.start();
// THIS IS WHERE THE PROBLEM IS...
function ac_TL(event:TimerEvent):void
{
var tl_character = new characterArray[Math.floor(Math.random() * characterArray.length)]();
tl_holder.addChild(tl_character);
}
what is the right way to code this?