Tutorial|Basic Moving

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:

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:

stop();

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

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:

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

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

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.

Thanks much nathan… BTW, I like your site.

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

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

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

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.

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!

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


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 :smiley: :stuck_out_tongue:

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

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


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

ah thats kind of u :slight_smile: :stuck_out_tongue: signifer

no bomb your code is wrong


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


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;
}
}

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


}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:)

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…

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

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