Experiencing a strange problem using the modulus operator.
Inside a function I have the following code:
var vValue1 = passed_MC._x - this.Maze_Horizontal_offset;
var vValue2 = 36;
var vTheResult = vValue1 % vValue2;
trace ("vValue1 = " + vValue1);
trace ("vTheResult = " + Number(vTheResult));
And here are the results I am getting from the trace statements:
vValue1 = 324
vTheResult = 5.6843418860808e-14
It's a result of rounding errors. The _x value is a float, and so there's a
very small leftover value at the bottom end of the decimal places. Notice
that your vTheResult is very, very small.
You can avoid the problem by taking Math.round(vValue1) % vValue2.
Danny
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com