# Stumped on easiest of things (controlling a MC)

**URL:** https://forum.kirupa.com/t/stumped-on-easiest-of-things-controlling-a-mc/262952
**Category:** flash
**Created:** [June 11, 2008, 11:43am UTC](https://forum.kirupa.com/t/stumped-on-easiest-of-things-controlling-a-mc/262952 "2008-06-11T11:43:04Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mainy](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@mainy](https://forum.kirupa.com/u/mainy)
#### Post date: [June 11, 2008, 11:43am UTC](https://forum.kirupa.com/t/stumped-on-easiest-of-things-controlling-a-mc/262952/1 "2008-06-11T11:43:04Z")

</div>

Hi,

I am hoping you can help, but I have a really dumb question.

I am still learning actionscript 3 so I decided to look at some tutorials on the internet to help. All I am trying to achieve is move a movie clip using the arrow keys. The problem is, it is driving me insane!

Basically, I tried copying a tutorial but recieved compiling errors. So I downloaded the code and it works perfectly. So I decided to copy and paste that code into my own flash document which uses the same graphics and instance names - BUT it still doesnt run at all! I get about 10 compiling errors about “Access to Undefined property”. I know it is more than likely a simple problem, like a spelling mistake - but can someone help?

I can upload a recording of my steps I take which may assist in understanding what went wrong

---

<div class="post-metadata">

### Author: ![mainy](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@mainy](https://forum.kirupa.com/u/mainy)
#### Post date: [June 11, 2008, 1:04pm UTC](https://forum.kirupa.com/t/stumped-on-easiest-of-things-controlling-a-mc/262952/2 "2008-06-11T13:04:37Z")

</div>

Oops, sorry. I guess that would help

> 

var speed:Number = 4;  
object\_mc.onEnterFrame = function() {  
if (Key.isDown(Key.RIGHT)) {  
this.\_x = this.\_x+speed;  
} else if (Key.isDown(Key.LEFT)) {  
this.\_x = this.\_x-speed;  
}  
if (Key.isDown(Key.UP)) {  
this.\_y = this.\_y-speed;  
} else if (Key.isDown(Key.DOWN)) {  
this.\_y = this.\_y+speed;  
}  
};

What i find weird is that it works in one flash program, then when copy and pasted over it gets compiling errors.

---

<div class="post-metadata">

### Author: ![Iamthejuggler](https://avatars.discourse-cdn.com/v4/letter/i/ecc23a/32.png) [@Iamthejuggler](https://forum.kirupa.com/u/Iamthejuggler)
#### Post date: [June 11, 2008, 1:05pm UTC](https://forum.kirupa.com/t/stumped-on-easiest-of-things-controlling-a-mc/262952/3 "2008-06-11T13:05:49Z")

</div>

\_x and \_y are now just x and y in as3.

---

<div class="post-metadata">

### Author: ![Fidodo](https://avatars.discourse-cdn.com/v4/letter/f/779978/32.png) [@Fidodo](https://forum.kirupa.com/u/Fidodo)
#### Post date: [June 11, 2008, 1:17pm UTC](https://forum.kirupa.com/t/stumped-on-easiest-of-things-controlling-a-mc/262952/4 "2008-06-11T13:17:33Z")

</div>

Also, for AS3 it’s better to use the EventListener model. You should look for an AS3 tutorial instead.

---

<div class="post-metadata">

### Author: ![Maqrkk](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@Maqrkk](https://forum.kirupa.com/u/Maqrkk)
#### Post date: [June 11, 2008, 1:37pm UTC](https://forum.kirupa.com/t/stumped-on-easiest-of-things-controlling-a-mc/262952/5 "2008-06-11T13:37:21Z")

</div>

Yep you should look into an Actionscript 3 tutorial if you want to learn it in Actionscript 3 😉  
For this example Actionscript 3 is probably alot longer, but it’s more obvious too.
