How to change standing position of a movieclip after walking animation?
I'm trying to make a game while also teaching myself actionscript at the same time so right now the project is just a demo. I have a movie clip and in it i have 4 frames. The first is a pair of legs standing facing right, second is legs standing facing left, third a walking animation facing right and the last is the same walking animation facing left. I want the legs to be in the standing position based on what direction they were walking after the left and right arrows are released. this is all done in a regular actionscript 3 file so i don't have any classes so if someone could give me a bit of advice or a reference that would be really great!
this is the code for the main stage
import flash.events.KeyboardEvent;
import flash.events.Event;
var kLeft = false;
var kRight = false;
var kUp = false;
var kDown = false;
player.stop();
addEventListener(Event.ENTER_FRAME, main);
stage.addEventListener(KeyboardEvent.KEY_DOWN, kd);
stage.addEventListener(KeyboardEvent.KEY_UP, ku);
function kd(k:KeyboardEvent){
if (k.keyCode==37) kLeft=true;
if (k.keyCode==39) kRight=true;
if (k.keyCode==38) kUp=true;
if (k.keyCode==40) kDown=true;
}
function ku(k:KeyboardEvent){
if (k.keyCode==37) kLeft = false;
if (k.keyCode==39) kRight = false;
if (k.keyCode==38) kUp = false;
if (k.keyCode==40) kDown = false;
}
function main(e:Event){
if (kLeft){
player.gotoAndStop("WALKING_L");
var direction = 1;
//direction will be 2 for right and 1 for left
}
else if(kRight){
player.gotoAndStop("WALKING_R");
direction = 2;
}
if (kLeft == false){
if (direction == 1){
player.gotoAndStop("STANDING_L");
}
else if (direction == 2){
player.gotoAndStop("STANDING_R");
}
}
if (kRight == false){
if (direction == 1){
player.gotoAndStop("STANDING_L");
}
else if (direction == 2){
player.gotoAndStop("STANDING_R");
}
}
}