AS3 Random repeat x seconds function
- by Lilk
Hi,
I have the following function:
function update(e:Event):void
{
var val:Number = Math.random() * 120;
rgb.r.x = rgb.r.y = val;
rgb.b.x = rgb.b.y = -val;
}
And im looping it with:
stage.addEventListener(Event.ENTER_FRAME, update);
But what I need to do would be something like:
Random number between 1 and 20
If the number is > 10
Call function Update
and keep caling it for 20 seconds
else
do nothing for 10 seconds
Repeat this block of code forever
Can someone help me write this please?