# Problem

**URL:** <https://forum.kirupa.com/t/problem/118645>\
**Category:** Uncategorized\
**Created:** [August 7, 2004, 6:49pm UTC](https://forum.kirupa.com/t/problem/118645 "2004-08-07T18:49:24Z")\
**Posts on this page:** 1\
**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:49pm UTC](https://forum.kirupa.com/t/problem/118645/1 "2004-08-07T18:49:24Z")

</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
