Generating Random multiple Instances From the library AS3
If someone can help me out with this problem I would greatly apprciate it. In AS3 I have 1 ball being exported out in actionscript in layer 1 from the library then gets placed on stage when the .swf publishes. here is the code:
The coin movieclip represents the "ball" and its the same movieclip over and over again. (works great no errors)
----code------------
// generates new Coin - Coin is the name of MovieClip in Library
// remember to export for Actionscript
var c1:Coin = new Coin();
var chosenNumsIndex1:uint = chosenNumsIndex;
trace("chosenNumsIndex1 outside " +chosenNumsIndex1);
// coin is placed at appropriate x and y coords
c1.x = kNum[chosenNums[chosenNumsIndex]].x;
c1.y = kNum[chosenNums[chosenNumsIndex]].y;
// addChild tells main timeline to display coin once it's generated.
this.addChild(c1);
What I want to achieve is to have 8+ random movieclips created and linked to the "coin" so when it gets exported it is not the same ball all the time so this is what I have for that:
var ballsArray:Array = [ball00,ball01,ball02,ball03,ball04,ball05,ball06,ball07,ball08];------- movieclips in the library
Question: how do I get the coin to read this array randomly so it doesnt go to "coin movieclip"and just play the one ball i would like it go play the ball of arrays?
thank you very much in advance
