Our Flash tutorials provide you with step-by-step instructions on how to create beautiful Flash animations and integrate them into your website.  Home Flash & Swish Flash Tutorials Create a Controllable Running Man
Your Ad Here

Create a Controllable Running Man


Requirements

  • Flash MX or higher.

Preview

Click on the Flash Movie to give it control, then alternate the left and right arrow keys to run.

1. Start out by creating a new document with a frame rate around 24.

2. Create a new movie clip (ctrl+F8) and name it "man".

3. In the first frame of the "man" movie clip draw a stick figure in a walking position.

4. In the Timeline, click the second frame and press F6 to create a new Keyframe. Move and rotate the arms and legs to make it look like the arms and legs have switched from front to back to back to front.

5. Click on the first frame. Open the actions panel and type

stop();

6. Return to scene 1 and open the library (ctrl+L).

7. Drag the "man" movie clip from the library to the bottm center of the Stage. In the Property Inspector change the instance name to "mcMan".

8. Make another new movie clip (ctrl+F8) and name it "scenery". Make sure the registration is the upper left.

9. This will be the background, you can draw anything from a tree to a picture of a city.

10. Return to scene 1. In the library (ctrl+L) right click on scenery and select linkage.

11. Check the box next to export for ActionScript. Make sure the identifier is scenery. Click OK.

12. Click on the first frame. Open up the actions panel and enter in the following code:

stop();
var speed = 0;
var back = .3;
var leftIsDown = true; //this is to make sure the user is pushing left and right
keylistener = new Object();
keylistener.onKeyDown = function()
{
     var k = Key.getCode();
     if(k==Key.LEFT && !leftIsDown)
     {
          mcMan.gotoAndStop(1);
          speed++;
          leftIsDown = true;
     }
     if(k==Key.RIGHT && leftIsDown)
     {
          mcMan.gotoAndStop(2);
          speed++;
          leftIsDown = false;
     }
}
Key.addListener(keylistener);
 
function addScenery() //call this function whenever you want scenery added
{
     attachMovie("scenery","scenery",getNextHighestDepth());
     scenery._x=400; //set x greater than the screen size
     scenery._y=100;
}
addScenery();
onEnterFrame = function()
{
     if(speed>=0)
     {
          scenery._x-=speed; //this moves the tree back
          speed-=back; //this slows down speed...friction
     }
     if(scenery._x<0-scenery._width) //this deletes the scenery after it is off the stage
     {
          removeMovieClip("scenery");
          addScenery();
     }
}

13. Now test your movie. To run, alternate pressing the left and right keys.



Author's URL: Tutorial Scene
Thank you for voting.
Rate this Materials:
Bad 
1 2 3 4 5 Excellent
print this page subscribe to newsletter subscribe to rss

Internet & computing Flash is a vector-based moving graphics format created by Macromedia for the publication of animations on the World Wide Web. More Flash & Swish: Most Popular Materials | Fresh Materials | More Flash Tutorials at FlashPerfection.com

Add comments to "Create a Controllable Running Man"

Only registered users can write comment

No comments yet...