# Functions

**URL:** <https://forum.kirupa.com/t/functions/41128>\
**Category:** Uncategorized\
**Created:** [January 26, 2004, 12:59am UTC](https://forum.kirupa.com/t/functions/41128 "2004-01-26T00:59:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![InsaneMonk](https://avatars.discourse-cdn.com/v4/letter/i/ce7236/32.png) [@InsaneMonk](https://forum.kirupa.com/u/InsaneMonk)\
**Post date:** [January 26, 2004, 12:59am UTC](https://forum.kirupa.com/t/functions/41128/1 "2004-01-26T00:59:35Z")

</div>

Why does this code not work?:  
in frame:  
[AS]function movement(object, key, xspeed, yspeed) {  
if (Key.isDown(key)) {  
object.\_x += xspeed;  
object.\_y += yspeed;  
}  
}[/AS]

in mc:  
[AS]onClipEvent (enterFrame) {  
movement(this, Key.RIGHT, 10, 0);  
movement(this, Key.LEFT, 0, 10);  
}[/AS]
