++ is just another way of doing it (and more popular) - doesnt make += 1 wrong, just a little unconventional since += 1 is so much harder to type than ++
there’s no real way to stop an onClipEvent(enterFrame), as I think you’ve seen (or discovered). Using an if condition like that is the best way to prevent the actions within from going on. You can further improve its effectiveness, however, as with how you have it now, the onEnterFrame is still adding 1 to calculation even when its no longer being used. A simple “flag” variable can be used instead - something that will be changed within the if statement that would further prevent it from running again:
onClipEvent(load){
// set up variables
calculation = 0;
doCalculation = true; // our flag
}
onClipEvent(enterFrame){
if(doCalculation){ // if true
// do stuff
calculation++; // add 1 to calculation
if (calculation > 100) doCalculation = false; // if condition false, code within ignored
}
// else is not needed since there's nothing else to do anyway
}
so doCalculation here is changed to false based on whether or not the calculation counter reaches 100 or not. This is quick because its contained within the if block and a boolean (true or false) flag variable is used to make it easily managable and readable for that matter.
yes, “calculation += 1” would work too, but “calculation = calculation += 1” results in NaN
That’s cool Sen, I’ll have to keep that kind of thing in mind next time I have to do something like this. You wouldn’t by chance happen to know how much it improves the efficiency by would you?