NSurveyor .. I'm afraid you code has an (actual) bug. alphaOnce is a
timeline variable of the clip where the code live, but then you refer to it
in the clearInterval as mc.alphaOnce .. and the mc is not the same clip.
In any case, this method of keeping track of the interval id is not good.
eg if you call an interval more than once, then you'll lose the old interval
id, as there is just one variable being used to keep track of it. As a
technique, it is better for the interval to keep track of its own interval
id so it can kill itself, and not rely on the caller (or other clip) to keep
the variable holding the interval id. BTW: Here is a slight variation on my
code from before that passes the clip and the interval delay to the
function:
function alphaFadeIn(clip, intervalDelay) {
// keep track of alpha, clip and interval number in 'settings' object
var settings = new Object;
settings.alpha = 0;
settings.clip = clip;
// set off the fade interval, remember interval number in settings
settings.interval = setInterval (
function (settings) {
// bump up the alpha
settings.alpha += 1;
settings.clip._alpha = settings.alpha;
// if faded in to 100%, then clear interval so we stop
if (settings.alpha >= 100) {
clearInterval(settings.interval);
}
},
intervalDelay, settings
);
}
alphaFadeIn ( title_mc, 200 );
--
Jeckyl
[quoted text, click to view] "NSurveyor" <saif7463@yahoo.com> wrote in message
news:d9stqs$msv$1@forums.macromedia.com...
> Why not do something like this?
>
> alpha(title_mc);
> function alpha(mc){
> mc._alpha = 0;
> alphaOnce = function(mc){
> mc._alpha++;
> if(mc._alpha>=100){
> clearInterval(mc.intervalID);
> }
> }
> mc.intervalID = setInterval(alphaOnce,200,mc);
> }