PDA

View Full Version : If statement every 10 points


dcole.ath.cx
02-19-2006, 04:37 AM
What is the right way to do something like this:

if (_i=0, _root.score.text=10_i, _i++) {
}

or

if (_i=0, _root.score.text=10*_i, _i++) {
}

this will set the var. i to be 0, then check to see if the score is equal to iX10 (var multiplied by 10), then add 1 to the var and try again...


------
Once I get that to work, I may go _i-- because it may not find an answer..
(the script I have shown above is PHP (which I know) but most action script I know is 98% like PHP

Thanks

Paerez
02-19-2006, 05:03 AM
the way a for loop works is in three parts: initialization, break test, and the modifying statement. The first one sets i to its initial value, the second part decides when the loop stops, and the third is a statement that is run on every loop. So using "_root.score.text=10*_i" is incorrect for the second statement, it should be inside and if statement.

Assertnfailure
02-19-2006, 08:29 AM
He's not even using a for loop, he's using an if statement.

for(i=0; i<_root.score.text/10; i++)

try that

Paerez
02-21-2006, 08:16 PM
If you want to see if X is a multiple of Y (if score is a multiple of 10) just do:
if (X % Y == 0)

or, if (_root.score.text % 10 == 0)

that returns true if the score is a multiple of 10.