Vathian
10-12-2008, 04:25 AM
var tstArray:Array = [a_mc, b_mc, c_mc];
trace(tstArray);
stage.addEventListener(MouseEvent.CLICK, addletter);
function addletter (MouseEvent):void
{
var t:Number = Math.floor((Math.random()*tstArray.length));
addChild(tstArray[t]);
}
Basically what I'm attempting is to call a random movieclip (all of which have "export for actionscript" ticked) and then display it on the screen.
It currently randomly pulls from the array but I cannot seem to get it to display it on the stage when clicked.
I receive this error:
"TypeError: Error #1034: Type Coercion failed: cannot convert c_mc$ to flash.display.DisplayObject. at Untitled_fla::MainTimeline/addletter()"
It also, when traced what's in the array, presents each as a class:
"[class a_mc],[class b_mc],[class c_mc]"
Am I going the completely wrong direction here?
Thanks in advance for any and all help!
trace(tstArray);
stage.addEventListener(MouseEvent.CLICK, addletter);
function addletter (MouseEvent):void
{
var t:Number = Math.floor((Math.random()*tstArray.length));
addChild(tstArray[t]);
}
Basically what I'm attempting is to call a random movieclip (all of which have "export for actionscript" ticked) and then display it on the screen.
It currently randomly pulls from the array but I cannot seem to get it to display it on the stage when clicked.
I receive this error:
"TypeError: Error #1034: Type Coercion failed: cannot convert c_mc$ to flash.display.DisplayObject. at Untitled_fla::MainTimeline/addletter()"
It also, when traced what's in the array, presents each as a class:
"[class a_mc],[class b_mc],[class c_mc]"
Am I going the completely wrong direction here?
Thanks in advance for any and all help!