嗨,希望有人可以在 AS3 中帮助我。下面是每 3 秒生成 1 个球的代码。库中有一个名为“硬币”的影片剪辑,每 3 秒在舞台上导出一次。
问题:我想要实现的是创建 8 个以上的随机影片剪辑并将其链接到“硬币”,因此当它被导出时,它始终不是同一个球,所以这就是我所拥有的:
var ballsArray:Array = [ball00,ball01,ball02,ball03,ball04,ball05,ball06,ball07,ball08];---- --- 库中的影片剪辑
问题:我如何让硬币随机读取这个数组,这样它就不会进入“硬币”电影剪辑“只玩一个我希望它去玩随机球的球
非常感谢你
creates timer that runs every 3 seconds. Number of times it runs
is determined by the length of chosenNums array (which is the number
of numbers chosen)
var timer:Timer = new Timer(3000, selectedNums.length);
timer is listening for itself to trigger, calls chuckBall()
timer.addEventListener(TimerEvent.TIMER,chuckBall);timer.addEventListener(TimerEvent.TIMER_COMPLETE, ballChuckingComplete);
chuckBall generates coins
函数chuckBall(事件:TimerEvent):无效{
generates new Coin - Coin is the name of MovieClip in Library
remember to export for Actionscript
var c1:Coin = new Coin();
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);
trace(chosenNums[chosenNumsIndex])
pull appropriate movieclip out of array and play to darken.
mcArray[chosenNums[chosenNumsIndex] - 1].play();
fill in bottom numbers
increments chosenNumsIndex so the next time chuckBall runs
it pulls the next element of the chosenNums array.
chosenNumsIndex ++;