# What is the AS3 version of this AS2 code ?

**URL:** https://forum.kirupa.com/t/what-is-the-as3-version-of-this-as2-code/638042
**Category:** Uncategorized
**Created:** [April 8, 2018, 10:10am UTC](https://forum.kirupa.com/t/what-is-the-as3-version-of-this-as2-code/638042 "2018-04-08T10:10:02Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Bracer](https://avatars.discourse-cdn.com/v4/letter/b/ac91a4/32.png) [@Bracer](https://forum.kirupa.com/u/Bracer)
#### Post date: [April 8, 2018, 10:10am UTC](https://forum.kirupa.com/t/what-is-the-as3-version-of-this-as2-code/638042/1 "2018-04-08T10:10:02Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)
#### Post date: [April 9, 2018, 5:19am UTC](https://forum.kirupa.com/t/what-is-the-as3-version-of-this-as2-code/638042/2 "2018-04-09T05:19:42Z")

</div>

Are you detecting the mouse movement direction? If so, try this: [https://www.kirupa.com/developer/flashcs3/detecting\_direction\_mouse\_movement.htm](https://www.kirupa.com/developer/flashcs3/detecting_direction_mouse_movement.htm)
