Welcome to WebmasterWorld Guest from 54.159.143.84

Forum Moderators: open

Message Too Old, No Replies

adjust speed of alpha change?

   
7:30 pm on Jan 11, 2010 (gmt 0)

5+ Year Member



Hi,

I have the following simple function to change the _alpha value.


function fadeIn() {
this._alpha += 25;
}

I assign this function to my movie clips:


greybar1_mc.onEnterFrame = fadeIn;
greybar2_mc.onEnterFrame = fadeIn;
menu_mc.onEnterFrame = fadeIn;
t_username.onEnterFrame = fadeIn;

The problem is that its all happening rather quickly.

Is it possible to adjust the speed and maybe also add an Easy In ?

Thanks!

8:51 pm on Jan 11, 2010 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



In frame 1 of the main movie,

var fadeIncrement:Number=25;
var fadeSpeed:Number=0.5;

then

greybar1_mc.onEnterFrame = setTimeout(_root.fadeSpeed,fadeIn());
greybar2_mc.onEnterFrame = setTimeout(_root.fadeSpeed,fadeIn());
menu_mc.onEnterFrame = setTimeout(_root.fadeSpeed,fadeIn());
t_username.onEnterFrame = setTimeout(_root.fadeSpeed,fadeIn());

and

function fadeIn() {
this._alpha += _root.fadeIncrememt;
}

This may not be entirely correct but is posted for an idea. The idea is you should be able to control the "fade speed" via setTimeout(). You may have to monitor the value of setTimeout and apply clearTimeout() to avoid recursive problems with setTimeout. See manual, don't have working code handy. :-)

Also note the movement of "25" to a variable that can be accessed by any object, this allows you to put all your variables in one place, frame 1 AS layer.