Q&A: In Flash actionscript 2.0, how do you change one movie Clip to another.?

Question by cricket_playah: In Flash actionscript 2.0, how do you change one movie Clip to another.?
In a game I am making, a character can be moved either left or right. The character must face the direction he is going, so i created two movie clips, one for each direction. What is the code i must use to change the left facing movie clip, to the right facing movie clip and viceversa when the left and right arrow keys are pressed.

Best answer:

Answer by James
You need to make another MC for the character.

On the first frame put the left direction MC, with a stop(); and on the second frame you put the right direction MC, again with a stop();.

Click on the first frame and call it “charLeft” and call the second frame “charRight”.

Then on the main MC you put the following AS:
onClipEvent(enterFrame){
if(Key.isDown(Key.RIGHT)){
this._x += 10;
this.gotoAndStop(“charRight”);
if(Key.isDown(Key.LEFT)){
this._x -= 10;
this.gotoAndStop(“charLeft”);
}
}
}

Good luck! =]

Give your answer to this question below!

Get the book now