Hi, I have been trying to add a child (ball) randomly on stage with a timer every certain time or with ENTER_FRAME, but I can't get it to work. In both cases it just add the first one and then stops, even though the timer keeps on working!
Any idea?
Thanks!!
Here is the code:
Actionscript Code:
//Classes
import com.greensock.*;
import flash.ui.Keyboard;
import flash.display.MovieClip;
import flash.events.MouseEvent;
//Variables
var max:Number = 580
var min:Number = 20
var ball:MovieClip = new Pelota ();
var randomNumber:Number = Math.round(Math.random() * (max - min) + min);
var timer:Timer = new Timer(1000, 5);
timer.addEventListener(TimerEvent.TIMER, onTimer, false, 0, true);
timer.start();
function onTimer(evt:TimerEvent):void {
addChild(ball);
ball.x = randomNumber
TweenLite.to(ball, 3, {y:504});
trace (timer);
}