Random alpha change

Hi people. I want to make each of the squares (pictured below) change alpha every second or so. (fading).

Is actionscript needed to do this? can anyone help?

Cheers

Use yourMC._Alpha = number to set the alpha (do it in a function)
Use setInterval(functionName, interval) to call the function every “interval”.
and stop when alpha = 0;
:slight_smile:

or…

onEnterFrame = function() {
myMC._alpha = random(0,100);
}

i think that’s the syntax… :slight_smile:

:p:

cheers for the quick responce but i get this error:

Error Scene=Scene 1, layer=Layer 2, frame=1:Line 2: Wrong number of parameters; random requires exactly 1.
myMC._alpha = random(0,100);

Total ActionScript Errors: 1 Reported Errors: 1

ah… right…

for (var i = 0; i<=10; i++) {
ball.duplicateMovieClip(“ball”+i, i);
ball._alpha = random(100);
ball._x = i*70
}

there ya go. did that just for you. i’ve got the fla if you wanna see it :stuck_out_tongue:

:p:

function alfachange (targetmc){if(targetmc._alpha >0){targetmc._alpha = targetmc._alpha - 10}}
setInterval(alfachange , 1000)

thanks!!

yeah, id love ta c the FLA.

cheers.

it’s for flash mx 04… lemme know if you need an mx.

i have get it to work, but i dont want all those random balls. just 1 ball with a random changing alpha.

cheers

ok.

onEnterFrame = function() {
box._alpha = random(100);
}

throw that on a frame and see what happens. give your squares the instance of box.

:p:

thats the one fella, cheers!
i knew i could rely on you guys.

Is there anyway i could make the alpha fade to the changing alpha instead of it just jerkin?

that’s a bit more advanced… let’s see here…

onEnterFrame = function() {
newAlpha = random(100);
box._alpha += newAlpha;
}

try that, lemme know.

:p:

//edit, actually, i don’t think that will work… i’ll play w/ it in flash.

no it didnt work. but dont need ta mess about with it tho, im happy with the one you gave us before.

thanks alot.

poo… flash sucks… someone else’s gonna have to help ya :wink: