View Full Version : var counter thingy - easy peasy (no really)
ericinho
February 17th, 2003, 10:59 AM
I have a SWF that loops on the main.
now I want that after 4 or 5 times of looping it does an action.
I know that with Var I can count and then with a little action I can instruct Flash that when a var value is reached it executes an action.
But how again do I do that?
(it was something with varofsumthing = "+1"
if varofsumnthing == "5"
gotoandplay(whatever)
hope you lot can help me out :)
alethos
February 17th, 2003, 01:31 PM
if(counterVariable++ == 5){
// Do something.
}
Just make sure you initialize counterVariable first. :)
-Al
ericinho
February 17th, 2003, 04:47 PM
so my varofsumthing = "+1" was actually correct???
wow! ;)
ericinho
February 17th, 2003, 05:10 PM
in one frame I have this to either continue to play if the varcount did not reach 3 or to stop if it did...
if (this.countvar++ == 3) {
this.gotoAndStop(347);
}
else {
this.gotoAndPlay(347);
}
and this action to set the var with each loop with an increase of 1
this.countvar +=1;
but, as you guessed... It don't work :)
alethos
February 17th, 2003, 09:35 PM
variable++ is the same as variable += 1
So in my code, the variable is incremented in the IF statement.
Now that I have a better idea of what you want, try this in frame 347:
if (this.countvar == 3) {
this.stop();
} else {
this.gotoAndPlay(346);
}
You have to go to the previous frame. Going to the same frame won't work (I think). And of course, make sure you have this in a frame before 346:
this.countvar = 0;
And you need to increment your counter somewhere with your
this.countvar += 1;
or
this.countvar++;
-Al
ericinho
February 18th, 2003, 04:12 AM
works fine!
thanks mate!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.