AS3 Random repeat x seconds function
Posted
by Lilk
on Stack Overflow
See other posts from Stack Overflow
or by Lilk
Published on 2010-05-31T14:41:08Z
Indexed on
2010/05/31
14:43 UTC
Read the original article
Hit count: 154
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?
© Stack Overflow or respective owner