Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Loop

Status
Not open for further replies.

phej

Technical User
Feb 8, 2005
22
US
God, this shouldn't be this hard!

I am trying to loop a few frames over and over until a counter equals a certain number. And instead of reaching the set number and moving on, I'm stuck in an infinate loop.

What am I doing wrong here?


// Set Variable
shake = 0;

//Raise count by 1
var shake = +1; ((also, this frame has the "play" label))

//Loop until X
if (shake = 3) {
gotoAndPlay("after shake");
} else {
gotoAndPlay("play");
}

I've tried everything I can think of...
 
there are 3 errors in your code in context:

Code:
// Problem: declaring while incrementing and not when instantiating to value 0
shake = 0;
// Solution: 
var shake = 0;

// Problem: operators are reversed 
var shake = +1;
// Solution:
shake++; // (or shake += 1);

// Problem: using assignment and not equality test
if(shake = 3)
// Solution:
if(shake == 3)

i haven't looked further than these issues, but if this doesn't help, let me know, and i'll dig deeper.

Mike
 
That's it, thanks!

I'm so rusty at my AS, it's annoying.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top