all groups > flash actionscript > december 2005 >
You're in the

flash actionscript

group:

Image Flicker randomly


Image Flicker randomly Abel.P
12/26/2005 1:44:06 PM
flash actionscript:
Hello there.

I have an image of a lamp turned off and another with the same lamp on.
I need to do it flicker several times but with random intervals.

Do you have any idea?
Any suggestion?
Any link?

Thank you.
Abel.
Re: Image Flicker randomly Peter
12/28/2005 1:28:03 AM
Well since it needs to be in random intervals probably the fastest way
to hack something like that together is using as follows:

function flickerImage() {
var rand1 = Math.round(Math.random()*5));
if(rand == 5) {
image_mc._visible = false;
} else {
image._visible = true;
}
}


flickerInterval = setInterval(flickerImage,100);


Now what that does is call the flickerImage interval every 100
milliseconds, get a random number between 0 and 5. If the random number
is equal to 5 it sets the visibility your image (embedded in a movieclip
with instance name image_mc) to false, otherwise sets it to true.

By tweaking the random range and setInterval time interval you can
influence the speed and random flickering.

Hope this helps!
Peter



[quoted text, click to view]
AddThis Social Bookmark Button