# Tutorial|Basic Moving

**URL:** https://forum.kirupa.com/t/tutorial-basic-moving/186101
**Category:** programming
**Created:** [April 19, 2006, 1:23am UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101 "2006-04-19T01:23:15Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Insane\_Knux](https://avatars.discourse-cdn.com/v4/letter/i/439d5e/32.png) [@Insane\_Knux](https://forum.kirupa.com/u/Insane_Knux)
#### Post date: [April 19, 2006, 1:23am UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101/1 "2006-04-19T01:23:15Z")

</div>

Ok, first, make your MC that will be your character, make 2 MC’s, one inside the first frame of your character MC, and make him just sitting there. Now put on that frame:

```auto
stop();

```

That makes him just sit there, or ‘idle’. Now make a second MC in the second frame of you character that shows your character running. On that frame put this:

```auto
stop();

```

This will stop it from automatically changing frames. Now, on your character MC put this code:

```auto
onClipEvent(enterFrame){
        if (Key.isDown(Key.RIGHT)){
                _xscale =+ 100;
                _x += 10;
                this.gotoAndStop(2);
        } else if (Key.isDown(Key.LEFT)){
                _xscale =- 100;
                _x -= 10;
                this.gotoAndStop(2);
        } else {
            this.gotoAndStop(1);
        }
}

```

This looks complicated, but it’s not.  
It means ‘if the right key is down, move to the right, and then if it was left a second ago, lets turn it turn it to the right… but if the left key is down, lets go left and if it was right a second ago, lets make it left… but maybe theyre not pressing anything? lets just stop altogether!’  
That’s it, the end. Comments accepted, but don’t be to harsh, this was my first tutorial. :lol:

---

<div class="post-metadata">

### Author: ![bombsledder](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bombsledder](https://forum.kirupa.com/u/bombsledder)
#### Post date: [April 19, 2006, 1:55am UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101/2 "2006-04-19T01:55:34Z")

</div>

this is the ugliest tutorial i have ever seen. UGLY your posting a noob code on a intermediate level of knowing flash

---

<div class="post-metadata">

### Author: ![Insane\_Knux](https://avatars.discourse-cdn.com/v4/letter/i/439d5e/32.png) [@Insane\_Knux](https://forum.kirupa.com/u/Insane_Knux)
#### Post date: [April 19, 2006, 2:08am UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101/3 "2006-04-19T02:08:44Z")

</div>

Like I said, this is my first tutorial I’ve ever made.  
Sorry to hear you disapprove of it.

---

<div class="post-metadata">

### Author: ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)
#### Post date: [April 19, 2006, 2:27am UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101/4 "2006-04-19T02:27:47Z")

</div>

FFS Bomb. Dont be so rude. I hate that. People start somewhere. This may help someone who is new to flash… helpibng them to learn to walk before they try to run. Forgive me if Im wrong… but I havent seen you bring out a tutorial. The title clearly states its \*\*basic \*\*movement. But I guess you didnt see that:look:

I say, Good work Knux, keep at it, you’ll get there.

---

<div class="post-metadata">

### Author: ![Insane\_Knux](https://avatars.discourse-cdn.com/v4/letter/i/439d5e/32.png) [@Insane\_Knux](https://forum.kirupa.com/u/Insane_Knux)
#### Post date: [April 19, 2006, 2:29am UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101/5 "2006-04-19T02:29:09Z")

</div>

Thanks much nathan… BTW, I like your site.

---

<div class="post-metadata">

### Author: ![lone\_wild\_wolf](https://avatars.discourse-cdn.com/v4/letter/l/3da27b/32.png) [@lone\_wild\_wolf](https://forum.kirupa.com/u/lone_wild_wolf)
#### Post date: [April 19, 2006, 2:29am UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101/6 "2006-04-19T02:29:20Z")

</div>

So true.actually it was pretty good considering it is a first.keep it up Knux  
BTW you site link isnt opening Knux

---

<div class="post-metadata">

### Author: ![Insane\_Knux](https://avatars.discourse-cdn.com/v4/letter/i/439d5e/32.png) [@Insane\_Knux](https://forum.kirupa.com/u/Insane_Knux)
#### Post date: [April 19, 2006, 2:41am UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101/7 "2006-04-19T02:41:12Z")

</div>

Thanks… and I guess I forgot to make the index… I just put the menu up lol… Now it works…

---

<div class="post-metadata">

### Author: ![bombsledder](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bombsledder](https://forum.kirupa.com/u/bombsledder)
#### Post date: [April 19, 2006, 10:35am UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101/8 "2006-04-19T10:35:43Z")

</div>

ok so im a noob and i just got done installing flash and i look at my first tutorial this one \>.\< i would probably have quit flash no offense but like i said its a noob code on an intermediate level of knowing flashes interface

---

<div class="post-metadata">

### Author: ![Joppe](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@Joppe](https://forum.kirupa.com/u/Joppe)
#### Post date: [April 19, 2006, 2:11pm UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101/9 "2006-04-19T14:11:19Z")

</div>

I dont know … It doesnt matter if its your first or twohundredfiftysecond tutorial… I mean sure it matter in the style of writing, you’ll get better as you write more. But you should give more indepth explaniations. As Bomb^ stated above, you should have a bit higher AS knowledge before start writing tutorial. Maybe you are an AS guru but likes writing this way, so no offence.

---

<div class="post-metadata">

### Author: ![Skinny\_T](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Skinny\_T](https://forum.kirupa.com/u/Skinny_T)
#### Post date: [April 19, 2006, 3:02pm UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101/10 "2006-04-19T15:02:00Z")

</div>

My first movement codes where similar to this so I’ll approve. But there are better out there. Keep it up though, tutorials are hard to write so I’ll give you a thumbs up :thumb:. I’d suggest looking at the tutorials on this site and look how they are presented. Then maybe you have a tutorial in mind that’s not currently here (i know theres alot). So keep up the good work!

---

<div class="post-metadata">

### Author: ![Ghettobird](https://avatars.discourse-cdn.com/v4/letter/g/b3f665/32.png) [@Ghettobird](https://forum.kirupa.com/u/Ghettobird)
#### Post date: [April 19, 2006, 5:12pm UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101/11 "2006-04-19T17:12:07Z")

</div>

[FONT=Courier New][COLOR=#000000][/COLOR][/FONT][FONT=Courier New][/FONT]

```auto

onClipEvent(load) {
movespeed = 10;
}
onClipEvent(enterFrame){
if (Key.isDown(Key.RIGHT)){
_x += _root.movespeed;
}
if (Key.isDown(Key.LEFT)){
_x -= _root.movespeed;
}
if (Key.isDown(Key.UP)){
_y -= _root.movespeed;
}
if (Key.isDown(Key.D N)){
_y += _root.movespeed;
}
}

```

GIRLPOWERRRRRRRRRR 😃 😛

---

<div class="post-metadata">

### Author: ![signifer123](https://avatars.discourse-cdn.com/v4/letter/s/858c86/32.png) [@signifer123](https://forum.kirupa.com/u/signifer123)
#### Post date: [April 20, 2006, 12:46am UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101/12 "2006-04-20T00:46:45Z")

</div>

I was gonna do something to help this move more off track but changed my mind…i’ll let you win this time GhettoBird 😛

This shows he understands what he’s writing(i think) and isn’t just spewing code, thats a good thing

---

<div class="post-metadata">

### Author: ![bombsledder](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bombsledder](https://forum.kirupa.com/u/bombsledder)
#### Post date: [April 20, 2006, 1:59am UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101/13 "2006-04-20T01:59:47Z")

</div>

```auto

onLoad=function(){
movespeed = 10;
}
onEnterFrame=function(){
if (Key.isDown(Key.RIGHT)){
mc._x += _root.movespeed;
}else if (Key.isDown(Key.LEFT)){
mc._x -= _root.movespeed;
}else if (Key.isDown(Key.UP)){
mc._y -= _root.movespeed;
}else if (Key.isDown(Key.DOWN)){
mc._y += _root.movespeed;
}
}

```

and for those of you who like writing code on the frames

---

<div class="post-metadata">

### Author: ![Ghettobird](https://avatars.discourse-cdn.com/v4/letter/g/b3f665/32.png) [@Ghettobird](https://forum.kirupa.com/u/Ghettobird)
#### Post date: [April 20, 2006, 5:54am UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101/14 "2006-04-20T05:54:05Z")

</div>

ah thats kind of u 🙂 😛 signifer

---

<div class="post-metadata">

### Author: ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)
#### Post date: [April 20, 2006, 5:54am UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101/15 "2006-04-20T05:54:57Z")

</div>

no bomb your code is wrong

```auto

onLoad=function(){
movespeed = 1;
}
onEnterFrame=function(){
if (Key.isDown(Key.RIGHT)){
mc._x += _root.movespeed;
}else if (Key.isDown(Key.LEFT)){
mc._x -= _root.movespeed;
}else if (Key.isDown(Key.UP)){
mc._y -= _root.movespeed;
}else if (Key.isDown(Key.DOWN)){
mc._y += _root.movespeed;
}
}

```

and there is no point for the onLoad as it is automatically part of the onload

```auto

movespeed = 1;
onEnterFrame=function(){
if (Key.isDown(Key.RIGHT)){
mc._x += _root.movespeed;
}else if (Key.isDown(Key.LEFT)){
mc._x -= _root.movespeed;
}else if (Key.isDown(Key.UP)){
mc._y -= _root.movespeed;
}else if (Key.isDown(Key.DOWN)){
mc._y += _root.movespeed;
}
}

```

---

<div class="post-metadata">

### Author: ![bombsledder](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bombsledder](https://forum.kirupa.com/u/bombsledder)
#### Post date: [April 20, 2006, 10:36am UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101/16 "2006-04-20T10:36:10Z")

</div>

i like onLoad for clean code? and which part of my code is wrong?

---

<div class="post-metadata">

### Author: ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)
#### Post date: [April 20, 2006, 10:42am UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101/17 "2006-04-20T10:42:08Z")

</div>

```auto

}else if (Key.isDown(Key.LEFT)){
mc._x -= 10 _root.movespeed;
}else if (Key.isDown(Key.UP)){
mc._y -= 10 _root.movespeed;
}else if (Key.isDown(Key.DOWN)){
mc._y += 10 _root.movespeed;
}

```

Im sure its just something you overlooked:)

---

<div class="post-metadata">

### Author: ![bombsledder](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bombsledder](https://forum.kirupa.com/u/bombsledder)
#### Post date: [April 20, 2006, 11:26am UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101/18 "2006-04-20T11:26:30Z")

</div>

hmm all i did is copy and past the code from ghetto and change it work with frames didn’t write it so maybe something happened when i was cutting :S

fixed it anyways i don’t even know how a 10 got in there since i didn’t type it wierd…

---

<div class="post-metadata">

### Author: ![GPP](https://avatars.discourse-cdn.com/v4/letter/g/848f3c/32.png) [@GPP](https://forum.kirupa.com/u/GPP)
#### Post date: [April 21, 2006, 5:09am UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101/19 "2006-04-21T05:09:10Z")

</div>

> [@bombsledder](#):
>
> so will some one please tell me how to make peolple move

Your a \*\*\* bombsledder… dont diss people, when you were a noob you were begging for a script on basic movement: [http://kirupa.com/forum/showthread.php?t=45636](http://kirupa.com/forum/showthread.php?t=45636)

---

<div class="post-metadata">

### Author: ![Ghettobird](https://avatars.discourse-cdn.com/v4/letter/g/b3f665/32.png) [@Ghettobird](https://forum.kirupa.com/u/Ghettobird)
#### Post date: [April 21, 2006, 5:25am UTC](https://forum.kirupa.com/t/tutorial-basic-moving/186101/20 "2006-04-21T05:25:17Z")

</div>

lol Thats 2 years ago,  
he learned alot in those past 2 years

[Next page](https://forum.kirupa.com/t/tutorial-basic-moving/186101.md?page=2)
