• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Tweening Buttons

You can tween buttons just as you do any other kind of symbol instance and create moving menus and interfaces that still respond to the pointer and carry out actions assigned to them.

To apply a motion tween to a button:

From the Insert menu, choose New Symbol, and create a button symbol.

Return to the main movie Timeline, and drag an instance of the button symbol onto the Stage. In the Property Inspector, give a name to your button instance.

Create a motion tween as you normally would for a graphic instance.

Insert new keyframes, move or transform each instance, and then choose Motion Tween in the Property Inspector.

Create a new Layer, select the first keyframe and open the Actions panel.

Assign an event handler to the keyframe as previously described, coding in the form:

myButton_btn.onRelease = function(){
//some action

Test your movie.

Throughout its tween, the button instance is active and responds to your pointer (Figure 4.18).

Figure 4.18. This balloon is a button that floats up and down in a motion tween. The event handler for this button is assigned on the main Timeline (top). When the user clicks the moving balloon, Flash will send the user to a frame label called “balloonPop” (not seen here).

✓ Tip

  • Assigning the event handler on the first keyframe of the Timeline is a better approach than assigning the event handler to the button instance in this case. Doing so keeps the ActionScript assigned to the button independent of its motion tween, so you can insert, delete, or modify keyframes or retween without losing the button’s interactivity.

Comparing a Movie-Clip Instance with a Graphic Instance

How does a movie-clip instance differ from a graphic instance? If you create the same animation in both a movie-clip symbol and a graphic symbol and then place both instances on the Stage, the differences become clear. The graphic instance shows its animation in the authoring environment, displaying however many frames are available in the main Timeline. If the graphic symbol contains an animation lasting ten frames and the instance occupies four frames of the main Timeline, you will see only four frames of the animation. Movie clips, on the other hand, do not work in the Flash authoring environment. You need to export the movie as a .swf file to see any movie-clip animation or functionality. When you export the movie (you can do so by choosing Control > Test Movie), Flash plays the movie-clip instance continuously, regardless of the number of frames the instance occupies and even when the movie itself has stopped.

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint