Insert an additional layer so that you will now have two layers; name the top layer actions, and the bottom layer character.
On the first frame of the character layer, draw out your character facing to the left of the stage. Convert it into a movie clip and name it stand still. Right click on stand still in the library and select duplicate, name the duplicate walk left. Double click on the walk left symbol in the library and animate him walking right. IMPORTANT NOTE: Don’t actually make him move to the right; just animate the legs as if he was walking right.
When you have done that, click back to the main timeline.
Now right click on the walk left movie clip in the library and name the duplicate walk right.
Double click on the walk right movie clip to enter it timeline and then select modify from the top menu options, transform and flip horizontal. Now click back to the main timeline.
On the first frame of the character drag an instance of the stand still move clip to the centre of the stage, give it an instance name of standStill. Double click on this move clip and insert a blank keyframe at frame 2. Then drag an instance of the walk left move clip to the centre of the stage making sure it is in the same position as the stand still move clip was. Insert another blank keyframe where, then drag an instance of the walk right movie clip from the library and position in the centre of the stage, as before make sure this is in the same position the walk left was, only is will be facing the opposite direction.
Insert a new layer, and name it actions, right click on the first frame and select actions, add the following code:
Stop();
Now click back to the main timeline.
Right click on the first frame of the actions layer, and select actions, add the following code:
//if the left arrow key is down, go to frame to of this movie clip and also move left.
standStill.onEnterFrame = function() {
if(Key.isDown(Key.LEFT)) {
this._x+=4;
this.gotoAndStop(2);
}
else if(Key.isDown(Key.RIGHT)) {
this._x-=4;
this.gotoAndStop(3);
}
//if none of the above is happening, stop on frame 1
else this.gotoAndStop(1);
}
Well done, that is all you need to do.
As I always say: any questions Email me at: learn_flash_pro_makeitsimple_now@hotmail.com
No comments:
Post a Comment