PDA

View Full Version : stopping an if statement



mojoNYC
May 23rd, 2003, 03:18 PM
hi all-
i'm trying to keep my animations processor-friendly, so i'm trying to figure out ways to stop algorithmic animations once they've finished--can someone tell me if the else stop(); i've put in here does the trick, or will this keep evaluating on every enterFrame?




onClipEvent(enterFrame){
if (myAlpha <=100){
myAlpha=myAlpha +1;
this._alpha=myAlpha;
}else stop();
}


thx,
-mojo

Voetsjoeba
May 23rd, 2003, 03:40 PM
onClipEvent(enterFrame){
if (myAlpha <=100){
myAlpha=myAlpha +1;
this._alpha=myAlpha;
} else {
stop();
}
}


You forgot the {}'s after else.

mojoNYC
May 23rd, 2003, 03:47 PM
thanks for picking that up (i typed it outside of flash)... so will this stop it from evaluating after of exceeds the max value?

Voetsjoeba
May 23rd, 2003, 03:56 PM
Yes and no. It will keep checking if it's true or false. A solution might be using an extra frame, and use gotoAndStop to that frame, so that there will be no onClipEvent(enterFrame) in the extra frame. Like this:

onClipEvent(enterFrame){
if (myAlpha <=100){
myAlpha=myAlpha +1;
this._alpha=myAlpha;
}else {
pathtoyourmc.gotoAndStop(extraframenumber);
}
}

Sorcerer
May 23rd, 2003, 04:24 PM
instead of stop use


else {
delete this.onEnterFrame
}

mojoNYC
May 23rd, 2003, 06:56 PM
thanks, both of you!
sorcerer, that's the stuff--i guess it's a weird addiction, trying to do everything in a single frame!

:)mojo