Adobe flash cs4 Game tutorial: Character Movement and Animation

Adobe flash cs4 Game tutorial: Character Movement and Animation

FLA<::>Adobe flash cs4 Game tutorial: Character Movement and Animation Learn to create Movement and Animation with characters Adobe Flash CS4 and action script 3. Hero: www.flyingyogi.com AS3 File: www.senocular.com

22 comments:

Anonymous said...

hey i found this tutorial to be simple enough to understand. but i have sprites with more than two frames. im using old mortal kombat sprites and the walking/standing both have 6-7 frames. i think this may be my problem. but it is coming up with errors and everytime i try n fix them another pops up. can u help me with this and tell me what im doing wrong? tvishous@aim.com is my email. also could u help me out on how to begin making a basic side scrolling fighting game. i just want to incorporate punching and jumping for now. pleez help much apreciated

Anonymous said...

please contact me at tvishous@aim.com as i could really use ur input on a couple different flash projects. i am new to cs4 and as 3.0. thanks

Vladimir said...

Hi, nice tutorial! I have a problem with animation here. My walking animation has 4 frames, as in your tutorial, but when i pressing button appears only first frame and when i release button animation start looping again.
My code:
hero_mc.gotoAndStop('still');

var Key:KeyObject = new KeyObject(stage);
stage.addEventListener(Event.ENTER_FRAME,onenter);
function onenter(e:Event):void{
if (Key.isDown(Key.RIGHT))
{
hero_mc.gotoAndStop('walking');
hero_mc.x+=5;
hero_mc.scaleX=1;

}
}

Can someone help me?

Unknown said...

great tutorial.
i was wondering if you could do this same tutorial on another instance.
i actualy want to use fireworks to create my character and then use flash to animate this character for the movement.

Gary Perrigo said...

Thanks, hard to find actionscript 3 tutorials!!! a huge help. Keep them coming. Nice and easy to understand.

Anonymous said...

I'm new to cs4, but I've tried to do everything according to the tutorial. Yet, when I want to test the movie, it says:

TypeError: Error #1009: Cannot access a property or method of a null object reference. at walking_fla::hero_1/frame1()

What's wrong?

Thanks!

Austone P said...

Hi, awesome tutorial! but i was wondering how could i use WASD to control the hero instead of the arrow keys thanks!

Waarith Abdul-Majeed said...

instead of using if if(Key.isDown(Key.RIGHT)){...}
You want to use a key code like this
if(Key.isDown(34)){...}
you can find all the key codes here key codes

Isaac said...

I love your tutorials, very simple and clear to understand. Although I have not tried this tutorial out for myself, it still seems easy enough to do. Thank you!

plutgamer said...

it does nothing

Lai Yeong King said...

Hey I wanted to ask that does this only works for movie clip? I wanted to do something like this on sprites but the gotoAndStop doesn't seems to work

And somehow I need the thing in sprite for some reason..

Thanks~

Anonymous said...

This is awesome, very clear and easy to understand.

Good work...keep them coming

Unknown said...

Hey dude i love your tutorials, just 1 thing, ive been trying to map keyboard keys to him moving left and right, so using A and D instead of LEFT and RIGHT, i was wondering how would i go about doing that. if you could email me the answer that would be awesome.

lewishardie@gmail.com

Anonymous said...

hi,

my character isn't moving to the left in this step with this code:

hero.gotoAndStop('still')
var Key:KeyObject = new KeyObject(stage);

stage.addEventListener(Event.ENTER_FRAME,onEnter);

function onEnter(e:Event):void{

if(Key.isDown(Key.RIGHT)){

hero.X += 5;
}

}



any idea?

Anonymous said...

to Vladimir:

Hi, had the same problem. This is my solution:

hero.gotoAndStop ('still');

var Key:KeyObject = new KeyObject(stage);
var taste:Boolean = true;

stage.addEventListener (Event.ENTER_FRAME,onEnter);

function onEnter (e:Event):void {



if (Key.isDown(Keyboard.RIGHT)) {

if (taste) {
hero.gotoAndStop('walking');
taste = false;

}
hero.x+=5;
hero.scaleX=-1;


}
else if (Key.isDown(Keyboard.LEFT)) {

if (taste) {
hero.gotoAndStop('walking');
taste = false;

}
hero.x-=5;
hero.scaleX=1;

}
else {

hero.gotoAndPlay('still');
taste = true;

}

}

Wes said...

Hello, thanks for helping me get started actionscripting. I can't seem to get my hero to goto 'walking' in all directions. If I remove the bottom else if statement he will walk endlessly and if I keep it there he only walks following the last key.isDown I entered. Am I missing something? I can move the else if statement but that has the same effect in different directions. Here's what I have, I added some code to keep him in my window, thanks for your help.



hero.gotoAndStop('still');

var Key:KeyObject = new KeyObject(stage);

stage.addEventListener(Event.ENTER_FRAME,onenter);

function onenter(e:Event):void
{


if(Key.isDown(Key.UP))
{
if(hero.y >=60) //keeps him on the screen
{
hero.y-=3;
hero.gotoAndStop('walking'); }
}


if(Key.isDown(Key.DOWN))
{
if(hero.y <= 375){
hero.y+=3;
hero.gotoAndStop('walking');
}
}


if(Key.isDown(Key.LEFT))
{
if(hero.x >=100){
hero.x-=3;
hero.scaleX=1;
hero.gotoAndStop('walking');
}
}


if(Key.isDown(Key.RIGHT))
{
if(hero.x <=600){
hero.x+=3;
hero.scaleX=-1;
hero.gotoAndStop('walking');
}
}


else
{
hero.gotoAndStop('still');
}
}

Anonymous said...

just one thing, you mispronounced yogi, the G in yogi is like the G in great, not like the G in tragedy. Your tutorial really helped a lot, thanks.

Jaewoo Park said...

Thnx for this great tutorial.

One thing however, I followed everything

and I made my character turn his face

to direction he's walking to.

The problem is, my character movieclip

DOES go to "walking" frame, but

he DOES NOT move.

Can you solve this plz?

Anonymous said...

I seem to be having a problem. Every time I try to start my sprite animation, I get and error saying "Symbol 'hero', Layer 'AS3', Frame 1, Line 1 1120: Access of undefined property hero."
I know I havethe right name for my obect in both my code and outside. Can you please list some possible reasons why this may happen? Thank you.

Anonymous said...

i am geting a 5007 and i don´t know why... T_T

Dor said...

I did it. i learned so much. thanks. A problem i hit was when you said to name movie clip as, "hero", i didnt know what i was supposed to be naming so i decided to start over and watch carefully. im very green. it was tough to keep track of all the different nested items.

Exciting vid with a brisk pace. Keep it up.

Anonymous said...

Not a good tutorial for beginners..