Making a random alpha effect 0-100%

Hey Kirupa people!!! Whats up!! id like to thank all of the people who helped me with the lemmings movement! I now have a new question at hand!!

I have a lightpost and i want the light on the post to randomly turn on and off the name of the glow is g_glow so how would i be able to do this??? (i want the alpha to go 0% - 100% randomly)
:ninja:

Id use _visible over _alpha if you are just going from 0-100. this will make things a little easier on flash.

What you can do is set a chance interval to determine how often your light has the chance to turn on or off. This is done using, of course, setInterval! There we just let the power of random do its thing.


flicker = setInterval(function(){if (random(2)) g_glow._visible = !g_glow._visible}, 30);

just change the 30 to alter frequency of flicker. Use clearInterval(flicker) to stop it.

since random(2) returns either a 0 (false) or 1 (true) theres a 50% chance the light will change its visibility on each interval. _visible = !_visible just makes true false or false true since its its own “not” visible. So if it IS visible visible equals not visible is not visible heh

question… where would i put that code i put that in the layer that the g_glow graphic is in but it didnt do anything!? Im really new to action scripting so bare with me!

i have it like this

layer 2 is g_glow graphic ontop of the light
layer 1 is the background

put it on a any frame where the clip is. In that same layer is fine. When you say graphic, you mean movieclip right? And make sure it has an instance name g_glow and not just its movieclip name (in the library)

actually when i mean graphic i mean graphic sybol , basically the g_glow graphic sybol is the when the LIGHT is turned on and the background picture is when the light is OFF! :slight_smile: should i make it into a movieclip?

well i just made it into a movieclip and named everything thanks dude!! it looks awesome!! ill post the website when im done , im just so psyched!!