# Functions problem

**URL:** <https://forum.kirupa.com/t/functions-problem/118644>\
**Category:** Uncategorized\
**Created:** [August 7, 2004, 6:30pm UTC](https://forum.kirupa.com/t/functions-problem/118644 "2004-08-07T18:30:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nico173](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@nico173](https://forum.kirupa.com/u/nico173)\
**Post date:** [August 7, 2004, 6:30pm UTC](https://forum.kirupa.com/t/functions-problem/118644/1 "2004-08-07T18:30:56Z")

</div>

I have a problem with functions. I want to make a function that moves the character and let him do a different thing like kicking or going down and jumping. Here is the code i have:

```auto
function enableKeyMovement(clip) {
 clip.onKeyDown = function() {
  this.onEnterFrame = this["key"+Key.getCode()];
 };
 clip.onKeyUp = function() {
  this.onEnterFrame = null;
 };
 clip.spd = 10;
 Key.addListener(clip);
 trace(clip);
}
//left - hold
MovieClip.prototype.key37 = function() {
 this._x -= 10;
 this.gotoAndStop(3);
};
//right - hold
MovieClip.prototype.key39 = function() {
 this._x += 10;
 this.gotoAndStop(2);
};
//jump - press or hold
MovieClip.prototype.key38 = function() {
 this.gotoAndstop(4);
 enableKeyMovement(ryu);
};
//down - hold
MovieClip.prototype.key40 = function() {
 this.gotoAndstop(5);
};
enableKeyMovement(ryu);

```

and i want the up key to be pressed once, the down key to be hold on to and when released it goes back, and the right and left to be hold on to and when released goes back to 1.

please help me,

thanks in advance,  
Nico

---

<div class="post-metadata">

**Author:** ![nico173](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@nico173](https://forum.kirupa.com/u/nico173)\
**Post date:** [August 9, 2004, 12:22am UTC](https://forum.kirupa.com/t/functions-problem/118644/2 "2004-08-09T00:22:41Z")

</div>

no one ? ☹
