Macromedia Flash 8 Bible Free Open Book

Macromedia Flash 8 Bible

Previous Page
Next Page

Targeting Movie Clips with Behaviors

In this section, you learn how to include the same interactivity of the previous exercise using Flash 8's behaviors feature. Behaviors, as we discussed in the last chapter, are self-contained blocks of ActionScript code that you can easily apply to elements in your Flash movie. In the following steps, you use behaviors instead of hand-coded actions to stop Stella's tail from wagging during the bark cycle.

On the CD-ROM 

As the starter file for this exercise, use the stella_absolute.fla document in the ch19/stella folder of this book's CD-ROM.

  1. Open the stella_absolute.fla document, and double-click the mcStella instance on the Stage.

  2. On the stellaClip timeline, double-click the mcBarkAnim instance (that is, Stella's head).

  3. On the barkAnimClip timeline, select frame 14 on the topmost actions layer. Open the Actions panel (F9), select the existing ActionScript code in the Script pane, and press the Delete or Backspace key to erase the code. Close the Actions panel when you're finished.

  4. Rename the topmost actions layer to behaviors. Re-select frame 14 of this layer, and open the Behaviors panel (Shift+F3). Click the Add Behavior (+) button and choose Movieclip ð Goto and Stop at frame or label. In the dialog box for this behavior, you'll notice a similar interface to that of the Insert Target Path dialog box. Expand the mcStella node, and choose the mcTailAnim instance. In the frame field, type the number 2. See Figure 19-7 for a review of the settings. Click OK to accept the settings.

  5. Select frame 20 of the lower actions layer, and erase the existing ActionScript code on this keyframe, as you did in Step 3.

  6. Rename the lower actions layer behaviors. With frame 20 of the lower behaviors layer selected, click the Add Behavior (+) button in the Behaviors panel, and choose Movieclip ð Goto and Play at frame or label. In this behavior's dialog box, expand the mcStella node, and choose the mcTailAnim instance. In the frame field, type the number 2. See Figure 19-8. Click OK to accept the settings.

    Tip 

    You can review the ActionScript code that the behavior uses by selecting its keyframe in the Timeline window and opening the Actions panel. Do not edit this code, however, or the behavior will not likely function properly.

  7. Save your document as stella_behaviors.fla, and choose Control ð Test Movie. The Flash movie should operate the same as the movie you created in the last section. When Stella barks, the tail stops wagging. When the bark is finished, the tail resumes wagging.

Image from book
Figure 19-7: The Goto and Stop at frame or label behavior settings
Image from book
Figure 19-8: The Goto and Play at frame or label behavior settings
On the CD-ROM 

You can find the completed example, stella_behaviors.fla, in the ch19/stella folder of this book's CD-ROM.


Previous Page
Next Page
Index: [A][B][C][D][E][F][G][H][I][J][K][L][M][N][O][P][Q][R][S][T][U][V][W][X][Y][Z]


     Main Menu
Table of Contents
Back Cover
Macromedia Flash 8 Bible
Foreword
Preface
Part I: An Introduction to Flash Web Production
Part II: Mastering the Flash Environment
Part III: Creating Animation and Effects
Part IV: Integrating Media Files with Flash
Part V: Adding Basic Interactivity to Flash Movies
Chapter 18: Understanding Actions and Event Handlers
Chapter 19: Building Timelines and Interactions
Movie Clips: The Key to Self-Contained Playback
Targets and Paths Explained
Targeting Movie Clips in Flash 8
Targeting Movie Clips with Behaviors
Integrating Behaviors with Movie Clips
Summary
Chapter 20: Making Your First Flash 8 Project
Part VI: Distributing Flash Movies
Part VII: Approaching ActionScript
Part VIII: Applying ActionScript
Part IX: Integrating Components and Data-Binding
Part X: Expanding Flash
Part XI: Appendixes
Index
List of Figures
List of Tables
List of Listings
List of Sidebars


More Books
PHP Hacks
Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax
The Koran (Holy Qur'an)
Macromedia Flash 8 Bible
Search Engine Optimization for Dummies
YouTube Traffic
PHP 5 for Dummies
Harry Potter and The Chamber of Secrets
Harry Potter and the Sorcerer's Stone
The Pilgrim's Progress
Wireless Hacks
Flash Hacks. 100 Industrial-Strength Tips & Tools
PayPal Hacks. 100 Industrial-Strength Tips and Tools
Amazon Hacks
Pdf Hacks
The Da Vinci Code
Google Hacks
The Holy Bible
Windows XP For Dummies
Harry Potter and the Half-Blood Prince
Seo Book
Upgrading and Repairing Networks
Macromedia Dreamweaver 8 UNLEASHED
Windows XP Annoyances
Windows XP Hacks
Microsoft Windows XP Power Toolkit
Teach Yourself MS Office In 24Hours
iPod & iTunes Missing Manual
PC Hacks 100 Industrial-Strength Tips and Tools
PC Overclocking, Optimization, and Tuning - 2th Edition
PC Hardware In A Nutshell 3rd Edition
PC Hardware in a Nutshell, 2nd Edition
Upgrading and Repairing PCs
Google for Dummies
MySQL Cookbook
Teach Yourself Macromedia Flash 8 In 24 Hours
PHP CookBook
Sams Teach Yourself JavaScript in 24 Hours
PHP5 Manual
Free Games Paper Airplanes
500 Juegos Gratis 500 Giochi Gratis 500 Jeux Gratuits 500 Jogos Gratis 500 Kostenlose Spiele