nice :)
here is a code for walking and turning with animation in a side scroller:
onClipEvent(load){
walk=2
wrdown=2
wldown=2
scale=1
speed=5
}
onClipEvent(enterFrame){
if(Key.isDown(68)){ //notes "d" is down
wrdown=1
}
else{
if(wrdown==1){ //cheks if "d" was down before and switch to breathing if it is up
walk=2
wrdown=2
this.gotoAndPlay("brea")
}}
if(Key.isDown(68)&&(walk==2)){ //walks right
walk=1;
if(scale==2){
this._xscale=-this._xscale
scale=1
this.gotoAndPlay("turn")
this._x=this._x+speed
}
else{
this.gotoAndPlay("walk");
this._x=this._x+speed
}
}
if(Key.isDown(65)){ //notes "a" is down
wldown=1
}
else{
if(wldown==1){ //cheks if "a" was down before and switch to breathing if it is up
walk=2
wldown=2
this.gotoAndPlay("brea")
}}
if(Key.isDown(65)&&(walk==2)){ //walks left
walk=1;
if(scale==1){
this._xscale=-this._xscale
scale=2
this.gotoAndPlay("turn")
this._x=this._x-speed
}
else{
this.gotoAndPlay("walk");
this._x=this._x-speed
}
}
if((Key.isDown(68))&&(Key.isDown(65))){ //cancels walking in case of both keys pressed
this.gotoAndStop("brea");
}}
so here is the deal:
you need a movie clip (appeared here only as "this") with 3 animations:
1.breath -first frame of the animation named brea
2.turn (character drawn from front)-first frame of the animation named turn
3.walk- first frame of the animation named walk
you need all the animations to loop ( "gotoAndPlay(animation first frame's name)" at the end of the animation).