[SIZE=1][SIZE=2]I noticed this when testing a (physics) project where particles are moved across the screen by adding their velocity to their x/y coordinates.
Here’s a small test to illustrate this strange issue (you can easily see it for yourself: name an mc on the stage “square”)[/SIZE]
import flash.events.Event;
var vx:Number = -1;
var vy:Number = -0.2;
var prevX:Number;
var prevY:Number;
addEventListener(Event.ENTER_FRAME, loop);
function loop(e:Event):void
{
square.x += vx;
square.y += vy;
vx *= 0.99;
vy *= 0.99;
trace(vx);
trace(square.x - prevX);
trace(vy);
trace(square.y - prevY);
trace();
prevX = square.x;
prevY = square.y;
}
[SIZE=2]The velocities are being nicely reduced ([FONT=Courier New]v_ *= 0.99[/FONT]) as shows from the traces
(from “1” trough “0.99”, “-0.109582…”, to “-0.00002483878…” to even “-5.562036804314994e-7”) as would be expected.
The problem is that the sprite gets moved with steps of approx one twip (0.05 pixel) even at ridiculously low values of vx/vy like “-6.027709330546002e-10”. This only happens when the amounts that get added to the x/y coordinates (vx/vy in this case) are negative. No problem with positive numbers. The creeping stops when the square hits a stage edge.
What the?
Thanks in advance for any input on this matter.
-Tomas
[/SIZE][/SIZE]