# How to i do this?

**URL:** <https://forum.kirupa.com/t/how-to-i-do-this/63003>\
**Category:** flash\
**Created:** [September 2, 2004, 6:35am UTC](https://forum.kirupa.com/t/how-to-i-do-this/63003 "2004-09-02T06:35:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xavier](https://avatars.discourse-cdn.com/v4/letter/x/2bfe46/32.png) [@Xavier](https://forum.kirupa.com/u/Xavier)\
**Post date:** [September 2, 2004, 6:35am UTC](https://forum.kirupa.com/t/how-to-i-do-this/63003/1 "2004-09-02T06:35:02Z")

</div>

how do i make a movie clip move using the spacebar, when it reaches a point it will move backwards.

anyone can help?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 2, 2004, 7:19am UTC](https://forum.kirupa.com/t/how-to-i-do-this/63003/2 "2004-09-02T07:19:57Z")

</div>

```auto

userKey= new Object();
userKey.onKeyDown= function(){
if (Key.getCode() == Key.SPACE){
your_mc._x+=10;
}
}
Key.addListener(userKey)

```

that will get you moving. well that is in mx terms, anyway.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 2, 2004, 7:40am UTC](https://forum.kirupa.com/t/how-to-i-do-this/63003/3 "2004-09-02T07:40:44Z")

</div>

erm… there is some errors. can u explain the functions? thx

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 2, 2004, 7:45am UTC](https://forum.kirupa.com/t/how-to-i-do-this/63003/4 "2004-09-02T07:45:58Z")

</div>

hmm the errors must be because of the difference in mx and mx 2004. it ran good for me in mx.

```auto

//creates a new object that will monitor keystrokes
userKey= new Object();

//when a keypress is detected, the userKey object will perform this function
userKey.onKeyDown= function(){

//if space bar is down, add 10 to the x value on your_mc
if (Key.getCode() == Key.SPACE){
your_mc._x+=10;
}
}

//add the userKey object to the Key class
Key.addListener(userKey)

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 2, 2004, 8:09am UTC](https://forum.kirupa.com/t/how-to-i-do-this/63003/5 "2004-09-02T08:09:24Z")

</div>

erm… wat do i type in the userKey? and the function() is wat i want it to do rite? sry i am a new learner

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 2, 2004, 8:15am UTC](https://forum.kirupa.com/t/how-to-i-do-this/63003/6 "2004-09-02T08:15:55Z")

</div>

userKey is an object that detects keypresses on your keyboard. the function is what it does when the spacebar is pressed.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 2, 2004, 8:27am UTC](https://forum.kirupa.com/t/how-to-i-do-this/63003/7 "2004-09-02T08:27:28Z")

</div>

so userKey= new object(); \<— this i dont change it?
