For a game with orders and clients I was trying to create the following situation:
Every half minute, a client should appear at the counter. In this case I have an array with 4 movieclips (4 clients). After 30 seconds I want the first randomly choosed client to appear at the counter (y = 200). This is my solution (wich obviously isn't the right way, forgive me):
var timer:Timer = new Timer(1000);
var elapsedTime:Number = 0;
timer.addEventListener(TimerEvent.TIMER, displaytime);
timer.start();
function displaytime(event:TimerEvent):void
{
elapsedTime++;
counterDisplay.text = String(elapsedTime);
}
if(elapsedTime == 30){
for (var i:uint = 0; i < mcArray.length; i++) {
mcArray[i].x = Math.floor( Math.random()*(stage.stageWidth) );
mcArray[i].y = 200;
addChild(mcArray[i]);
}
}
My question to you is: What am I doing wrong, and how can I accomplish this? Thanks in advance!