Animate a Continuous Quad Run Cycle With Flash

Jun 24th in Animation by Michael Chen

In this tutorial we'll create a quad run cycle. The animation will be created using simple lines. Along the way we'll cover a bit of work flow and animation theory, then near the end we'll use Motion Tween and ActionScript to move the animal across the screen.

PG

Author: Michael Chen

Michael Chen is a Flash Developer currently working in New Zealand. He has strong interests in Interactive Web Design and Animation.

Final Animation Preview

Let's take a look at the final animation we're aiming for:

Step 1: Decision Time

First decide what you want to animate (since different animals move in different ways). I'm going to animate a generic feline, so it'll move in a similar to a lion, cheetah, tiger, etc.

Step 2: References

I often study references if I don't know how the subject moves.

Here are some sites/books that I used:

Step 3: Anatomy

It's helpful to understand the anatomy of the animal, this way you can better visualize what is actually moving underneath the skin.

Here are a few books on animal anatomy:

Step 4: Drawing

Once you've spent enough time analyzing and studying the references, it's time to do some drawing. I normally prefer to do some planning on paper first, though some people prefer to go straight onto the computer and start animating. It doesn't really matter which method you choose, just as long as it works for you.

By the way, you don't have to be a great artist to draw. Simple lines are good enough, as long as you can understand your own drawings. Usually I'll draw the important poses that I'd like to see in the animation.

Step 5: Flash

Let's get started in Flash...

  1. Create a new .fla document.
  2. Set the dimensions to 560 x 400px.
  3. Set the stage color to black since I'll be drawing in white.

Change the dimensions and colors to suit your needs.

Step 6: Layer It Up

Create the following layers:

  • actions
  • animal
  • ground

Then lock the "actions" layer since it'll only contain ActionScript code.

Step 7: Frames Per Second (fps)

The fps for web animation varies quite a bit. All the way from 4 ~ 48fps. I'll be animating at 24fps.

Here are some other standards...

  • PAL - 25fps
  • NTSC - 30fps
  • Film - 24fps

To alter the fps, simply change it at the bottom of the timeline, or go to Modify > Document.

Step 8: Frame by Frame

There are many ways to animate in Flash, however I'll animate in a more traditional style whereby I'll draw each pose of the animation. I'll be using the "Pencil Tool" to draw. For the "Pencil Mode", I've selected the "Smooth" setting which means Flash will smooth out the lines as I draw.

Step 9: Ground

First select the "ground" layer and draw a straight line to represent the ground. Then lock the layer. The ground has a white (#FFFFFF) stroke colour and a stroke weight of 3.

Step 10: Poses

Go into the "animal" layer and start drawing the important poses. Generally they are the contacts and extreme poses. For the animal poses I've used a stroke weight of 5. Now, if you had planned this out in advance, you can simply redraw it all in Flash. If you want, you can also scan in your drawings and trace over them.

Note: You may want to look a steps 15 ~ 21 before you start animating.

Here are the poses I've drawn so far.

To extend the amount of frames for the "ground" layer, right-click the fourth frame and select "Insert Frame". This works even if the layer is "locked".

The small black dot on each frame indicates a "Keyframe" in Flash. To create a keyframe, right-click a frame and select "Insert Keyframe" or go to Insert > Timeline > Keyframe.

Step 11: Refining the Pose

It's highly likely that you'll want to make changes after drawing a pose. Simply select the "Selection Tool" then and move the mouse close to the line you want to modify. When the icon on the bottom right of the mouse changes to a "curve", click and drag the line.

Step 12: Timing

Once you're happy with your main poses, you can start to play around with the timing. If you test your movie now, it'll be too fast. Insert a few frames between the poses and play around with the timing. To add a frame, right-click a frame and select "Insert Frame" or go to Insert > Timeline > Frame.

Step 13: More Poses

Now let's add more poses in between.

Note: Feel free to readjust the timing in order to get the animation working as a whole.

Step 14: Even More Poses

We can even make it smoother by adding more inbetweens.

Step 15: Onion Skin

When animating, I find it useful to use the "Onion Skin" and "Onion Skin Outlines". These tools can show the contents for a range of frames, before and after the current frame. You can also increase or decrease the number of frames by dragging the circles on each end.

Step 16: Tips

Some of you may find animation easy while others may not. I've therefore provided some tips which will hopefully help you in the process.

  • Volume: One of the main things to be aware of when animating is that the volume should remain the same. The animal can squash and stretch as long as the volume is maintained.
  • Force and WEIGHT: When animating, always try to feel where the force and weight is travelling. Think about where the weight is at. Where is it coming from? Where is it travelling to?
  • Up and Down: From studying the references, I've noticed that the faster an animal moves, the less up-and-down movement it has. The same applies to their tail.
  • Planting feet: One other thing I noticed from the reference is the foot pattern. The feet usually plant in circular order. For example, let's say the first foot that plants on the ground is front-left (1). Then these would be the two possible orders...
      CCW
    1. front-left foot
    2. back-left foot
    3. back-right foot
    4. front-right foot
      CW
    1. front-left foot
    2. front-right foot
    3. back-right foot
    4. back-left foot

Step 17: Sliding Feet

Generally, animation cycles move at a constant speed. Thus when animating the legs, make sure that the difference between the distance of each foot (between the frames) are approximately the same. If not, the feet may look like they're sliding.

Step 18: Converting into Movie Clip

Now let's move the animation cycle across the screen. First, though, we'll need to convert the frames into a "Movie Clip". To convert frames on the main timeline to a Movie Clip:

  1. Select all the frames from the "animal" layer.
  2. Right-click and select "Copy Frames".
  3. Go to Insert > New Symbol...
  4. Name it "animal run cycle" and make sure the type is "Movie Clip".
  5. Click OK.

You should now be on the "animal run cycle" timeline. Right-click the first frame and select "Paste Frames".

Now go back to the main timeline by clicking the scene name (beneath the timeline). Then clear all the frames on the "animal" layer and drag "animal run cycle" from the library onto the stage.

Step 19: Motion Tween

Using Motion Tween we can move the animal across the stage so it seems like it's running across the screen. The distance you want to move for each frame should be equal to the difference between the position for the planted foot (between the frames).

We'll refer to the "difference" as "dX". Here is a formula which finds the "number of frames" given that you know the initial and final positions.

numberOfFrames = (finalXPosition - initialXPosition) ÷ dX

Here's an example:

An animal has an initial position at -50, a dX value of 11.5 and a final position at 610. Thus the amount of frames between its initial position and final position is...
= (610 - -50) ÷ 11.5
= 660 / 11.5
= 57 frames (rounded to the nearest integer)

To create Motion Tween:

  1. Select the "animal" layer.
  2. Right-click the first frame and select > "Create Motion Tween".
  3. Select the first frame and move the animal to its initial position.
  4. Right-click frame 58 and select "Insert Frame".
  5. Select frame 58 and move the animal to its final position.

Note: The actual final frame is 58 since the initial frame is 1 - the number of frames between the initial and final frame is 57.

Result:

Step 20: ActionScript

It's easier to move the animal using ActionScript since you don't need to worry about the formula and all you need to know is dX.

First make sure you have an instance of the "animal run cycle" on the stage. If not, go to the library panel and drag one out. Give it an instance name "animal_mc", then move the animal off screen to the left. Then select frame 1 in the "Action" panel and add the following code:

AS3:

var dX:Number = 11.5;

// Adds an enterFrame to "animal_mc".
animal_mc.addEventListener(Event.ENTER_FRAME, moveAnimal, false, 0, true);

// enterFrame function for "animal_mc".
function moveAnimal(evt:Event):void  {
	
	// The animal's x position increases by dX.
	evt.target.x += dX;
		
	// Move the animal back to the left when it moves off screen.
	if(evt.target.x > stage.stageWidth + evt.target.width)  {
		evt.target.x = -evt.target.width;
	}
}

AS2:

var dX:Number = 11.5;

// Adds an enterFrame to "animal_mc".
animal_mc.onEnterFrame = function()  {
	
	// The animal's x position increases by dX.
	this._x += dX;
	
	// Move the animal back to the left when it moves off screen.
	if(this._x > Stage.width + this._width)  {
		this._x = -this._width;
	}
}

Result:

Step 21: The Other Direction

Let's say that you wanted the animal to move the other way (right to left). Select "animal_mc" and go to Modify > Transform > Flip Horizontal.

Here is the new ActionScript code:

AS3:

var dX:Number = 11.5;

// Adds an enterFrame to "animal_mc".
animal_mc.addEventListener(Event.ENTER_FRAME, moveAnimal, false, 0, true);

// enterFrame function for "animal_mc".
function moveAnimal(evt:Event):void  {
	
	// The animal's x position decreases by dX.
	evt.target.x -= dX;
		
	// Move the animal back to the right when it moves off screen.
	if(evt.target.x < -evt.target.width)  {
		evt.target.x = stage.stageWidth + evt.target.width;
	}
}

AS2:

var dX:Number = 11.5;

// Adds an enterFrame to "animal_mc".
animal_mc.onEnterFrame = function()  {
	
	// The animal's x position decreases by dX.
	this._x -= dX;
	
	// Move the animal back to the right when it moves off screen.
	if(this._x < -this._width)  {
		this._x = Stage.width + this._width;
	}
}

Result:

Final Word

Thank you for reading this tutorial and I hope you have fun animating!


Enjoy this Post?

We'd love your vote!

User Comments

( ADD YOURS )
  1. PG

    bodhi June 24th

    wow!!!

    ( Reply )
  2. PG

    Halv June 24th

    Brilliant. Thank you very much. I’d like more stuff like that !

    ( Reply )
  3. PG

    Mário Santos June 24th

    Nice! :)

    Congrats!

    ( Reply )
  4. PG

    Vladimir June 24th

    Great tutorial!!
    Thanks

    ( Reply )
  5. PG

    André June 24th

    WOWW!!
    Amazing, i liked it very much, and i really will try this one!!!

    THANKS!!!!

    ( Reply )
  6. PG

    samBrown June 24th

    nice affect, great tut

    ( Reply )
  7. PG

    Has_n June 24th

    Incredible tutorial, really nice and really well done, thx a lot!!!!!

    ( Reply )
  8. PG

    Francois June 24th

    Very awesome :)

    ( Reply )
  9. PG

    Gregory Gunther June 24th

    This was a great tutorial. The smoothness in your animation for this run cycle is quite impressive. I will have to study and try this for myself. Thanks.

    ( Reply )
  10. PG

    Steven Aiello June 24th

    Fricking sweet! Now to practice my sketching skills = )

    ( Reply )
  11. PG

    henry June 24th

    seem like a helpful tutorial that can be applied to many projects thanks for the nice post!

    ( Reply )
  12. PG

    arnold June 24th

    nice tut!good help for my first animation in flash

    ( Reply )
  13. PG

    TPN June 24th

    WOW!

    ( Reply )
  14. PG

    Tom June 24th

    Only one quick question how do you work out the Dx i can see its the difference between the 2 frames but how do you measure this and what units is it bein measured in?

    ( Reply )
    1. PG

      Michael Chen June 26th

      Hi Tom,

      Simply turn on “Onion Skin”, then draw a line to measure the distance.

      Units are in pixels.

      regards,
      Mike

      ( Reply )
  15. PG

    Dan June 24th

    Best Flashtuts tut so far.

    ( Reply )
  16. PG

    LQDstudios June 24th

    One of the best tuts I have seen on this network in a while.

    ( Reply )
  17. PG

    Dario Gutierrez June 24th

    Great effect dude.

    ( Reply )
  18. PG

    Diego SA June 24th

    OH my God! That’s impressive! Awesome! You’re good!

    ( Reply )
  19. PG

    Ben June 25th

    That’s really impressive. Keep up the good work!

    ( Reply )
  20. PG

    Botox June 25th

    great…

    ( Reply )
  21. PG

    Yabadabadoo June 25th

    Thanks Michael, this was a great tut. You Rock!

    ( Reply )
  22. PG

    Ahmed Nuaman June 25th

    Very very good

    ( Reply )
  23. PG

    ph June 25th

    This is fu**ing AWESOME!!!

    ( Reply )
  24. PG

    ZephiR June 25th

    TY for this Tut! Awesome !

    ( Reply )
  25. PG

    Michael Chen June 26th

    Hi everyone,

    Thank you all for the feedback.

    regards,
    Mike

    ( Reply )
  26. PG

    tianovsky June 26th

    source link is broken

    ( Reply )
    1. PG

      Michael Chen June 28th

      Hi tianovsky,

      I’ll ask Ian to fix it. Thanks for letting us know.

      regards,
      Mike

      ( Reply )
    2. PG

      Ian Yates June 28th

      Sorry about that, my fault.. Link is fixed.

      ( Reply )
  27. PG

    Vega June 26th

    Very nice, will have to use this.

    Just curious what did u use to make this tutorial

    ( Reply )
    1. PG

      Michael Chen June 28th

      Hi Vega,

      I used:
      Dreamweaver,
      Flash,
      Fireworks,
      and Print Screen

      regards,
      Mike

      ( Reply )
  28. PG

    Kiran June 29th

    awesome tut.. thank u very much

    ( Reply )
  29. PG

    sam June 29th

    wow… It’s very nice. I’ll try to creat it,

    Thanx a lot,
    -Sam.

    ( Reply )
  30. PG

    zoran June 29th

    Thank you very, very much for sharing that with us!

    ( Reply )
  31. PG

    diodz June 29th

    what the f***…awesome tut…..

    ( Reply )
  32. PG

    aliaskajan June 30th

    very nice animation
    thank you!

    ( Reply )
  33. PG

    47 July 2nd

    Nice Work body

    ( Reply )
  34. PG

    e11world July 2nd

    I really enjoyed this tutorial and love the face that you put the code in AS2 as well. That’s super useful for people like me who didn’t get to AS3 yet.

    ( Reply )
  35. PG

    Vishu July 3rd

    incredible!…I’ll have try this even though i’m new to flash =)

    ( Reply )
  36. PG

    daniel July 3rd

    this is amazing and very well documented tut.
    cheers

    ( Reply )
  37. PG

    borbz July 4th

    thanks man, well done..

    ( Reply )
  38. PG

    Ananth July 4th

    Nice tutorial. Good learning. Thanks

    ( Reply )
  39. PG

    kalkiback July 6th

    This is a great tutorial for traditional animation. I am looking for relation between frame-rate, distance and numbers of frame for a smooth animation due to whenever i make a simple slide in flash it always pretty difficult to make a smooth sliding. If you have any suggestion or tutorial about that please reply me.

    ( Reply )
  40. PG

    rory July 13th

    Mind blowing!
    That run looks so realistic cant see any glinches in it at all…I’ll have to look at that code a few times before it sinks in though, I’m not that hot when it comes to action script. But worth the times, cheers for another awesome tutorial.

    ( Reply )
  41. PG

    Raul July 14th

    Great tutorial!,

    Thanks for the help

    ( Reply )
  42. PG

    Jonathan July 15th

    This looks really cool. Although the math part makes me nervous! 8)

    ( Reply )
  43. PG

    Pasquale July 15th

    I think the breakdown position between the contacts needs an actual down position to actually give it some weight. Weight is an essential fundamental to sell believability

    ( Reply )
  44. PG

    nooshin July 18th

    i am just going to cry >:D<

    ( Reply )
  45. Thank you for sharing

    ( Reply )
  46. PG

    happybrush July 21st

    How much time does it take to make an animation like this ? did you draw every frame from scratch or modified the nearest frames ? I think it’s very hard to stay constant to the body shape/size/position then drawing each frame.

    ( Reply )
  47. PG

    aşk July 22nd

    Congratulations, I really had a good run.

    ( Reply )
  48. PG

    snet July 24th

    nice! thanx…

    ( Reply )
  49. PG

    mhargot July 25th

    wonderful

    ( Reply )
  50. PG

    Noble Sebastian July 28th

    wow! its excellent..want more like that…

    ( Reply )
  51. PG

    Aleksandar August 11th

    great!

    ( Reply )
  52. PG

    Ravi August 25th

    Brilliant dude can u sent me some more examples flash animation
    on ravi_rko85@yahoo.in

    ( Reply )
  53. PG

    Ayesha September 4th

    I wud have loved to make it but i am not gud at drawing! but its amazing!

    ( Reply )
  54. PG

    ARUNRAJ September 13th

    GREAT WORK .

    ( Reply )
  55. PG

    Lef November 16th

    Fantasic!!! Need some practice to mastery^^
    Thanksss

    ( Reply )
  1. Arrow
    Gravatar

    Your Name
    November 16th