What is the AS3 version of this AS2 code ?


#1

checkX = function (dx, oldVal, newVal)
{
if (oldVal<newVal)
{
trace(“moving right”);
} else if (oldVal>newVal)
{
trace(“moving left”);
}
return newVal;
};
checkY = function (dy, oldVal, newVal)
{
if (oldVal<newVal)
{
trace(“down”);
} else if (oldVal>newVal)
{
trace(“up”);
}
return newVal;
};
this.watch(“xdir”, checkX);
this.watch(“ydir”, checkY);
this.onMouseMove = function()
{
xdir = _xmouse;
ydir = _ymouse;
};

Gosh I miss AS2 SO MUCH, things were so easy ! That Match function is MAGIC !
Copy this entire code into frame 1 of your AS2 file, it’s from a tutorial on this very site.


#2

Are you detecting the mouse movement direction? If so, try this: https://www.kirupa.com/developer/flashcs3/detecting_direction_mouse_movement.htm