1. Home
  2. Computing & Technology
  3. Animation

Flash Animation 17: Controlling Movie Clips With Buttons and ActionScripting

By , About.com Guide

7 of 8

Adding Button Commands to Control the Movie Clip

Since we animated the hat, we need to associate it with the button that says "Hat". Right-click on that button and select Actions. With the Actions window in Expert Mode (click the blue arrow in the upper right-hand corner and select Expert Mode), enter the following code:

on (release) {
ShortHat.gotoAndPlay(2) ;
}

You already know how the on (release) and gotoAndPlay commands work; we've told the button that when the mouse click releases, it needs to go to and play frame 2 (frame 1 has a stop on it, remember, so starting on frame 2 will play the animation). This difference is that in previous instances, we've told it to go to and play frame 2 of the current scene, or another scene; this time, we're directing it to an entirely separate timeline nested inside a movie clip. The part of the code that does that is:

ShortHat.

Adding this parameter before the gotoAndPlay command (the period acts as a separator) tells Flash that it needs to access the timeline inside the instance ShortHat of the movie clip HatShort, and then play from there.

And it's that simple. To see a demonstration of just the animated hat, click here.

Explore Animation
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Animation
  4. Flash Animation Tutorials
  5. Flash Animation 17: Controlling Movie Clips With Buttons and ActionScripting

©2009 About.com, a part of The New York Times Company.

All rights reserved.