Stopping an if statement

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

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

You forgot the {}'s after else.

thanks for picking that up (i typed it outside of flash)… so will this stop it from evaluating after of exceeds the max value?

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:

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

instead of stop use

[AS]
else {
delete this.onEnterFrame
}
[/AS]

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