all groups > flash actionscript > march 2004 >
You're in the

flash actionscript

group:

prototype onEnterFrame vs. setInterval



prototype onEnterFrame vs. setInterval szd
3/5/2004 8:28:47 PM
flash actionscript: OK, when a certain event happens (button push), I want a particular MC to fade
in. I made a prototype method and called the method during the event. When I
use onEnterFrame, the fade-in works. When I use setInterval, it does not (the
setInterval code is bracketed by /* and */).

Thanks,
szd


MovieClip.prototype.changeAlpha = function (){
this._alpha=0;
this.onEnterFrame=function (){
if (this._alpha <= 50){
this._alpha +=5;
trace("hi");
}else{
this._alpha = 55;
}
}
/*intervalAlpha= setInterval(function(){
trace("hi");
this._alpha += 5;
},5);
*/
}
Re: prototype onEnterFrame vs. setInterval Jack.
3/5/2004 9:31:13 PM
MovieClip.prototype.changeAlpha = function (){
this._alpha=0;
this.onEnterFrame=function (){
if (this._alpha <= 50){
this._alpha +=5;
trace("hi");
}else{
this._alpha = 55;
}
}
};

clip1.changeAlpha();
/////////////////////////////////
clip2._alpha = 0;

function test(mc){ trace(mc);
intervalAlpha = setInterval(function(){ trace("hi");
mc._alpha <= 50 ? mc._alpha += 5 : mc._alpha = 55;
mc._alpha <= 54 ? null : clearInterval(intervalAlpha);
},80);
};

btn1.onPress = function(){
test(clip2);
};

btn2.onPress = function(){
trace(clip1._alpha+" | "+clip2._alpha);
};

my 2c's ....hth ? :)
AddThis Social Bookmark Button