how to check, how many times the modulo % start over.
Hello,
Suppose you have an enterFrame that increases a value:
In this case the speed is increased by 4 every times.
my_value 4
my_value 8
my_value 12
my_value 16
my_value 20
my_value 24
my_value 28
my_value 32
my_value 36
my_value 40
my_value 44
my_value 48
my_value 52
this value is stored in a variable called my_value;
If you want to have a maximum and that the result values starts at 0 again, you can use the modulo %
In my example the maximum is 50. So i trace out (my_value%50) and see that it start over and does not
go over the 50. But how can i count how many times it reaches it's maximum?
[as]
//the code:
var my_value = 0;
var my_speed = 4;
var countloops = 0;
this.onEnterFrame = function() {
my_value += my_speed;
doSomething(my_value);
}
function doSomething(myvalue) {
var maxValue = myvalue%50;
if(maxValue>=50) {
trace("loop");
countloops++;
}
trace("maxValue:" + maxValue);
}
[/as]
Does anyone has a good idea to count the loops?
thanks!
Regards,
Chris.
