01.04.2015 Views

Flash MX Tutorials.pdf

Flash MX Tutorials.pdf

Flash MX Tutorials.pdf

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Flash</strong> <strong>MX</strong> <strong>Tutorials</strong><br />

<br />

Macromedia <strong>Flash</strong><br />

<strong>MX</strong><br />

<br />

®<br />

macromedia


Trademarks<br />

Afterburner, AppletAce, Attain, Attain Enterprise Learning System, Attain Essentials, Attain Objects for Dreamweaver,<br />

Authorware, Authorware Attain, Authorware Interactive Studio, Authorware Star, Authorware Synergy, Backstage, Backstage<br />

Designer, Backstage Desktop Studio, Backstage Enterprise Studio, Backstage Internet Studio, Design in Motion, Director,<br />

Director Multimedia Studio, Doc Around the Clock, Dreamweaver, Dreamweaver Attain, Drumbeat, Drumbeat 2000, Extreme<br />

3D, Fireworks, <strong>Flash</strong>, Fontographer, FreeHand, FreeHand Graphics Studio, Generator, Generator Developer’s Studio, Generator<br />

Dynamic Graphics Server, Knowledge Objects, Knowledge Stream, Knowledge Track, Lingo, Live Effects, Macromedia,<br />

Macromedia M Logo & Design, Macromedia <strong>Flash</strong>, Macromedia Xres, Macromind, Macromind Action, MAGIC, Mediamaker,<br />

Object Authoring, Power Applets, Priority Access, Roundtrip HTML, Scriptlets, SoundEdit, ShockRave, Shockmachine,<br />

Shockwave, Shockwave Remote, Shockwave Internet Studio, Showcase, Tools to Power Your Ideas, Universal Media, Virtuoso,<br />

Web Design 101, Whirlwind and Xtra are trademarks of Macromedia, Inc. and may be registered in the United States or in other<br />

jurisdictions including internationally. Other product names, logos, designs, titles, words or phrases mentioned within this<br />

publication may be trademarks, servicemarks, or tradenames of Macromedia, Inc. or other entities and may be registered in<br />

certain jurisdictions including internationally.<br />

Third-Party Information<br />

Speech compression and decompression technology licensed from Nellymoser, Inc. (www.nellymoser.com).<br />

Sorenson Spark video compression and decompression technology licensed from<br />

Sorenson Media, Inc.<br />

This guide contains links to third-party Web sites that are not under the control of Macromedia, and Macromedia is not<br />

responsible for the content on any linked site. If you access a third-party Web site mentioned in this guide, then you do so at your<br />

own risk. Macromedia provides these links only as a convenience, and the inclusion of the link does not imply that Macromedia<br />

endorses or accepts any responsibility for the content on those third-party sites.<br />

Apple Disclaimer<br />

APPLE COMPUTER, INC. MAKES NO WARRANTIES, EITHER EXPRESS OR IMPLIED, REGARDING THE<br />

ENCLOSED COMPUTER SOFTWARE PACKAGE, ITS MERCHANTABILITY OR ITS FITNESS FOR ANY PARTIC-<br />

ULAR PURPOSE. THE EXCLUSION OF IMPLIED WARRANTIES IS NOT PERMITTED BY SOME STATES. THE<br />

ABOVE EXCLUSION MAY NOT APPLY TO YOU. THIS WARRANTY PROVIDES YOU WITH SPECIFIC LEGAL<br />

RIGHTS. THERE MAY BE OTHER RIGHTS THAT YOU MAY HAVE WHICH VARY FROM STATE TO STATE.<br />

Copyright © 2002 Macromedia, Inc. All rights reserved. This manual may not be copied, photocopied, reproduced,<br />

translated, or converted to any electronic or machine-readable form in whole or in part without prior written approval of<br />

Macromedia, Inc.<br />

Acknowledgments<br />

Director: Erick Vera<br />

Producer: Wayne Wieseler<br />

Writing: Jody Bleyle, JuLee Burdekin, Mary Burger, Dale Crawford, Marcelle Taylor<br />

Instructional Design: Stephanie Gowin, Barbara Nelson<br />

Editing: Rosana Francescato, Lisa Stanziano, Anne Szabla<br />

Multimedia Design and Production: Aaron Begley, Benjamin Salles, Noah Zilberberg<br />

Print Design and Production: Chris Basmajian, Caroline Branch<br />

Second Edition: June 2002<br />

Macromedia, Inc.<br />

600 Townsend St.<br />

San Francisco, CA 94103


CONTENTS<br />

CHAPTER 1<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5<br />

What you should know . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5<br />

View the completed movie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6<br />

Analyze the stiletto.fla file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6<br />

Define properties for a new document and create a gradient background . . . . . . . . . . . 12<br />

Create and mask vector art . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21<br />

Tween bitmap effects within a movie clip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30<br />

Load dynamic text at runtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37<br />

Add animation and navigation to buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42<br />

Add streaming and event sounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47<br />

Organize your Library panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49<br />

Test download performance and publish the movie . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51<br />

The next steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54<br />

CHAPTER 2<br />

Introduction to ActionScript Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55<br />

View a completed movie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56<br />

Initialize the movie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59<br />

Save and retrieve information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64<br />

Display information in a dynamic text box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65<br />

Write an expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67<br />

Control the flow of the movie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70<br />

Create commands and reuse code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71<br />

Use a built-in object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76<br />

Test the movie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79<br />

The next steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81<br />

CHAPTER 3<br />

Introduction to Components Tutorial. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83<br />

Types of components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83<br />

View the completed form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84<br />

Create a form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85<br />

The next steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94<br />

3


CHAPTER 4<br />

Introduction to Learning Interactions Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . 95<br />

What you should know . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95<br />

What you’ll learn. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96<br />

Open a new document from a quiz template. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96<br />

Take a tour of the quiz template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96<br />

Test the quiz template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98<br />

View a completed version of the learning interaction tutorial file. . . . . . . . . . . . . . . . . 101<br />

Modify the Welcome page. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102<br />

Use assets from a shared library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106<br />

Modify a True or False interaction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108<br />

Modify a Fill in the Blank interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110<br />

Modify a Multiple Choice interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112<br />

About graphic distractors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114<br />

Modify a Drag and Drop interaction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114<br />

Modify a Hot Object interaction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118<br />

Modify a Hot Spot interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121<br />

Add an interaction to the Timeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126<br />

Modify the quiz results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127<br />

Publish the quiz for AICC Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129<br />

Moving on. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129<br />

4<br />

Contents


CHAPTER 1<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial<br />

This tutorial guides you through the process of creating a compelling Web experience with<br />

Macromedia <strong>Flash</strong> <strong>MX</strong>. By completing the tutorial, you’ll learn how to design a movie, from<br />

opening a new document to publishing the movie for Web playback. The tutorial takes<br />

approximately three hours to complete, depending on your experience, and will teach you how to<br />

do the following tasks:<br />

• Analyze a completed movie<br />

• Define document properties and create a gradient<br />

• Create and mask vector art<br />

• Tween bitmap effects within a movie clip<br />

• Load dynamic text<br />

• Modify buttons and add navigation<br />

• Add streaming and event sounds<br />

• Test and publish the movie<br />

We recommend that you complete the eight sections that comprise the tutorial in sequence,<br />

although you may choose to review only the sections that interest you. If you do complete the<br />

tutorial out of sequence, keep in mind that later sections assume you’ve mastered skills introduced<br />

in earlier sections.<br />

What you should know<br />

Before taking the tutorial, complete the seven lessons found in <strong>Flash</strong> Help. These interactive<br />

lessons created in <strong>Flash</strong> introduce you to the concepts you need to know to complete the tutorial.<br />

Lesson topics include the following:<br />

• Getting Started with <strong>Flash</strong> <strong>MX</strong><br />

• Illustrating in <strong>Flash</strong><br />

• Adding and Editing Text<br />

• Creating and Editing Symbols<br />

• Understanding Layers<br />

• Creating Buttons<br />

• Creating Tweened Animation<br />

To take a lesson, choose Help > Lessons, then select from the list.<br />

5


View the completed movie<br />

You can open a completed version of the tutorial movie to better understand how your finished<br />

file will appear.<br />

In this section, you’ll accomplish the following tasks:<br />

• Analyze the completed movie using the Property inspector and Movie Explorer<br />

• Examine a movie clip and discern its relationship to the main movie<br />

• View the types of assets included in the movie<br />

1 Within your <strong>Flash</strong> <strong>MX</strong> application folder, browse to <strong>Tutorials</strong>/<strong>Flash</strong>Intro and double-click<br />

stiletto.swf to open the completed movie in the stand-alone <strong>Flash</strong> Player.<br />

Published <strong>Flash</strong> movies have the SWF extension; documents in the authoring environment<br />

have the FLA extension.<br />

2 When the movie opens, watch the three views of the car fade in and out.<br />

You’ll create this animation by tweening bitmap effects within a movie clip.<br />

3 Listen to the sound that plays continuously while the movie plays. This is an example of a<br />

streaming sound.<br />

4 Roll over the three buttons along the lower right edge of the window to view the rollover effect,<br />

and to hear the event sounds included in each button.<br />

5 Click a button to see where it links, then close the browser that opened and return to the SWF file.<br />

6 After viewing the movie, click its close box.<br />

Analyze the stiletto.fla file<br />

It’s helpful to analyze the completed FLA file to see how the author designed the document. To<br />

analyze the file, you can view the properties for an object, view the Timeline and Stage, look at<br />

library assets, and use the Movie Explorer.<br />

6<br />

Chapter 1


1 In <strong>Flash</strong>, choose File > Open. Navigate to your <strong>Flash</strong> application folder and open <strong>Tutorials</strong>/<br />

<strong>Flash</strong>Intro/stiletto.fla.<br />

You now see the completed tutorial movie in the authoring environment.<br />

Drag the bar that separates the<br />

Stage from the Timeline<br />

2 To view all layers in the main Timeline, drag down the bar that separates the Stage from<br />

the Timeline.<br />

3 In the Timeline, unlock the Copy layer and the Images layer.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 7


View document properties<br />

The Property inspector lets you view specifications for selected objects. The specifications depend<br />

on the type of object selected. If you select a text object, for example, settings to view and modify<br />

text attributes appear.<br />

1 If the Property inspector isn’t open, choose Window > Properties.<br />

2 On the Stage, scroll down if necessary and select the rectangular block where descriptive text<br />

appeared in the finished SWF file. The text does not appear in the FLA file because it loads<br />

from an external TXT file into a dynamic text field.<br />

Text box<br />

In the Property inspector, you can view the size, style, and color of the text, among other attributes.<br />

If the Property inspector is not fully expanded, click the white triangle in the lower right corner.<br />

3 On the Stage, select the car.<br />

Movie clip settings replace the text settings. Movie clips are symbols with their own<br />

independent Timelines. You can think of them as movies within movies.<br />

8<br />

Chapter 1


View the movie clip<br />

Now you’ll open symbol-editing mode to view the Timeline for a movie clip.<br />

1 On the Stage, double-click the movie clip of the car.<br />

As you learned in the Creating Tweened Animation lesson, you define changes in animation in<br />

keyframes. When you scroll around the Timeline, note which layers have keyframes in them<br />

and which frames are keyframes.<br />

Beginning and intermediate keyframes that include content are indicated in the Timeline by<br />

solid circles, ending keyframes appear as small outlined rectangles.<br />

2 In the Timeline, select the playhead and drag it slowly across the frames.<br />

Watch how changes in action on the Stage correspond to changes in the Timeline. As you drag<br />

the playhead, the movie plays sequentially. You can add ActionScript, the <strong>Flash</strong> scripting<br />

language, to movies to make the playhead jump to specific frames.<br />

3 When you finish viewing the movie clip, do one of the following to return to the main movie:<br />

• Choose Edit > Edit Document.<br />

• Click the Back button.<br />

• Click Scene 1 above the Stage.<br />

View library assets<br />

The Library panel contains the symbols and imported objects in your document.<br />

1 If the Library panel isn’t open, choose Window > Library.<br />

2 Drag the Library panel to enlarge it, if necessary, to view the objects within the library.<br />

3 If the Artwork folder is not expanded, double-click it to view the objects in the folder.<br />

4 Click view1.png to view the image in the preview area at the top of the Library panel.<br />

5 Expand the other folders in the Library panel to view the assets included in the document,<br />

such as buttons and movie clips.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 9


6 When you finish viewing the assets, close the Library panel.<br />

Analyze the movie structure with the Movie Explorer<br />

The Movie Explorer helps you arrange, locate, and edit media. With its hierarchical tree structure,<br />

the Movie Explorer provides information about the organization and flow of a movie, especially<br />

useful when you analyze a movie authored by someone else.<br />

1 If the Movie Explorer is not already open, choose Window > Movie Explorer.<br />

2 If necessary, enlarge the Movie Explorer to view the tree structure within the pane.<br />

The Movie Explorer filtering buttons display or hide information.<br />

10<br />

Chapter 1


3 Click the pop-up menu in the title bar of the Movie Explorer, and verify that Show Movie<br />

Elements and Show Symbol Definitions are selected.<br />

4 Deselect the Show Frames and Layers button along the top of the Movie Explorer. Verify that<br />

the only filtering buttons selected are Show Text; Show Buttons, Movie Clips, and Graphics;<br />

Show ActionScripts; and Show Video, Sounds, and Bitmaps.<br />

5 Examine the list to view some of the assets included in the movie and to see their relationship<br />

to other assets.<br />

6 To expand an object or category, click the Plus (+) button to the left of the name<br />

7 Select the Show Frames and Layers filtering button. Scroll down to the Symbol Definitions<br />

category. With the category expanded, double-click the Car Animation movie clip.<br />

You’re now in symbol-editing mode for the movie clip.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 11


8 In the Movie Explorer, with the Car Animation category selected and expanded, expand the<br />

View 3 Fade icon, then double-click Frame 60.<br />

In the Timeline for the movie clip, the playhead moves to Frame 60 of the View 3 Fade layer.<br />

To view an item listed in the hierarchical tree, click the corresponding icon. If you click a frame<br />

icon, the playhead moves to that frame in the Timeline. If you click an asset, such as a bitmap<br />

image, the Property inspector displays the image settings. Double-clicking an icon that<br />

represents a symbol opens symbol-editing mode.<br />

9 Close the Movie Explorer. To close the document, choose File > Close.<br />

If you’ve made changes to the file, do not save them.<br />

Define properties for a new document and create a<br />

gradient background<br />

To learn how to create a movie in <strong>Flash</strong>, let’s start from the very first step in the process: opening<br />

a new file. Then, by completing this section, you’ll learn how to complete the following tasks:<br />

• Open a new file and define document properties<br />

• Create and transform a gradient background<br />

Open a new file<br />

Now you’re ready to create your own version of the tutorial movie.<br />

1 Choose File > New.<br />

2 Choose File > Save As.<br />

3 Name the file mystiletto.fla and save it within your <strong>Flash</strong> <strong>MX</strong> application folder, in the<br />

<strong>Tutorials</strong>/<strong>Flash</strong>Intro/My_Stiletto sub folder.<br />

Note: As you complete the tutorial, remember to save your work frequently.<br />

Define document properties<br />

Configuring document properties is a common first step in authoring. You can use the Property<br />

inspector and Document Properties dialog box to specify settings that affect the entire movie,<br />

such as the frames per second (fps) playback rate, and the Stage size and background color.<br />

1 If the Property inspector isn’t open, choose Window > Properties. In the Property inspector,<br />

verify that 12 is the number in the Frame Rate text box.<br />

The movie will play at 12 frames per second, an optimal frame rate for playing animations<br />

on the Web.<br />

Note: If the Property inspector is not fully expanded, click the white triangle in the lower right corner.<br />

12<br />

Chapter 1


2 The Background Color box indicates the color of the Stage. Click the down arrow on the<br />

Background Color box, then move the Eyedropper tool over the color swatches to view their<br />

hexadecimal values in the Hexadecimal text box.<br />

3 Find and click the gray color swatch with the hexadecimal value of 999999.<br />

Hexadecimal text box<br />

Select this shade of gray<br />

4 To resize the Stage, click the Size button, which indicates the size of the Stage. In the Document<br />

Properties dialog box, type 640 px in the first Dimensions text box and 290 px in the second<br />

Dimensions text box. Verify that Pixels is selected in the pop-up menu, and click OK.<br />

The Stage dimensions change to reflect the new settings of 640 x 290 pixels.<br />

Specify grid settings<br />

On the Stage, you can align objects along horizontal and vertical grid lines. Even when the grid is<br />

not visible, you can snap objects to it. Now you’ll modify the distance between the horizontal and<br />

vertical grid lines, and create a grid in alignment with the Stage borders.<br />

1 Choose View > Grid > Edit Grid.<br />

2 In the Grid dialog box, type 10 px in the grid width text box and 10 px in the grid height text box.<br />

3 Select Snap to Grid and verify that Show Grid is not selected.<br />

Objects will now snap to the grid, even when the grid is not visible.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 13


4 Verify that Normal is selected for Snap Accuracy, and click OK.<br />

Snap accuracy determines how close an object must be to a grid line before snapping to it.<br />

Create a gradient background<br />

A gradient displays subtle variations of a color, or transitions between two or more colors. In the<br />

finished tutorial file, the background is a gradient that blends black and dark blue with a<br />

transparent area that allows part of the gray Stage color to be displayed. You achieve this effect<br />

using the Color Mixer.<br />

Note: While gradients offer interesting effects in movies, overuse of gradients can adversely affect computer<br />

processor speeds and decrease the speed at which an animation plays. When designing a movie, consider both<br />

your artistic and performance requirements to determine the best use of gradients.<br />

Draw a rectangle<br />

Earlier in the tutorial, you created a grid that aligned against the Stage and allowed you to snap objects<br />

to the grid lines. Now you’ll draw a rectangle that snaps to the area of the grid bordering the Stage.<br />

1 In the pop-up menu above the right side of the Stage, enter 75% to view the entire Stage.<br />

This setting indicates your magnified or scaled-down view of the Stage. The setting does not<br />

affect the actual size of the Stage in your movie, which you specified in the Document<br />

Properties dialog box.<br />

2 In the toolbox, select the Rectangle tool.<br />

14<br />

Chapter 1


3 In the toolbox, click the Stroke Color control. Select No Stroke (the button with the red<br />

diagonal line above the color palette).<br />

The selected fill color of the shape is unimportant; you’ll soon change the color.<br />

4 Starting from the upper left corner of the Stage, drag to the lower right corner of the Stage to<br />

draw a rectangle that covers the Stage.<br />

When you release the pointer, the rectangle snaps to the edges of the Stage, along the hidden grid.<br />

Note: While completing the tutorial, you may find it useful to undo a change you’ve made. <strong>Flash</strong> can undo several<br />

of your recent changes, depending on the number of undo levels you have set in Preferences. To undo, choose<br />

Edit > Undo or press Control+Z (Windows) or Command+Z (Macintosh). Conversely, you can redo what you’ve<br />

undone by choosing Edit > Redo or pressing Control+Y (Windows) or Command+Y (Macintosh).<br />

Specify a color for the gradient<br />

Dark blue is the first color you’ll add to your gradient.<br />

1 In the toolbox, select the Arrow tool. On the Stage, click inside the rectangle to select the fill.<br />

When you drew the rectangle, the Property inspector displayed properties for the Rectangle<br />

tool. When you select a shape that has already been created, the Property inspector displays<br />

properties for the shape.<br />

2 If the Color Mixer is not open, choose Window > Color Mixer.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 15


3 To expand the Color Mixer, click the white arrow in the panel title bar.<br />

Click here to expand the panel<br />

4 If the Color Mixer is not fully expanded, click the arrow in the lower right of the panel.<br />

5 In the Fill Style pop-up menu, select Radial.<br />

6 Click the gradient slider to the left of the gradient bar to select it.<br />

Gradient bar<br />

Gradient slider<br />

16<br />

Chapter 1


7 Click the color box in the upper left corner of the window to open the color palette. Use one of<br />

the following methods to select dark blue:<br />

• Type 000066 in the hexadecimal value text box and press Enter or Return.<br />

• Move the eyedropper over the color swatches until you find the dark blue with the hexadecimal<br />

value of 000066, then click the swatch to select it.<br />

Click this shade of blue<br />

Change the alpha value<br />

In the Color Mixer, the Alpha text box indicates the transparency of the color, with 0% indicating<br />

that the color is completely transparent, and 100% indicating the color is completely opaque.<br />

You’ll specify an alpha value of 0% to create a gradient that includes dark blue and black along<br />

with the gray Stage color that shows through the transparent areas of the gradient.<br />

• In the Color Mixer, either type 0 in the Alpha text box and press Enter or Return, or move the<br />

Alpha slider to 0.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 17


Add a second gradient color<br />

You’ll now add black to the gradient.<br />

1 In the Color Mixer, click the gradient slider to the right of the gradient bar to select it.<br />

2 Click the color box to open the color palette and select the black with a hexadecimal value<br />

of 000000.<br />

Remember, you can either type the hexadecimal value in the Hexadecimal text box and press<br />

Enter or Return, or you can find and select the color swatch with the same hexadecimal value.<br />

Transform the gradient fill<br />

When you transform an object, you rotate, scale, or skew it. You can transform a fill using the Fill<br />

Transform tool.<br />

1 In the toolbox, select the Fill Transform tool. On the Stage, click anywhere inside the rectangle.<br />

An ellipse that indicates the shape and location of the gradient appears around the Stage. The<br />

ellipse has controls for the location, width, scale, and rotation of the radial gradient.<br />

Center placement<br />

Width<br />

Scale<br />

Rotation<br />

18<br />

Chapter 1


2 Drag the center control to the left of the Stage so that it’s approximately 1/3 of the distance<br />

from the left edge of the Stage, as shown in the following illustration.<br />

As you change the shape and placement of the ellipse, the shape and placement of the color<br />

transitions on the Stage change accordingly.<br />

3 Drag the square handle on the ellipse, which controls gradient width, to the left to make the<br />

ellipse narrower; the approximate shape of the ellipse is shown in the following illustration.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 19


4 Drag the circular middle handle, which controls the size of the gradient, to the right to make<br />

the ellipse larger, as shown in the following illustration.<br />

5 Drag the bottom circular handle, which controls the rotation of the ellipse, toward the left to<br />

rotate the ellipse to the approximate angle shown in the following illustration.<br />

20<br />

Chapter 1


Name and lock a layer<br />

The gradient shape appears on Layer 1 in the Timeline, currently the only layer in your<br />

document. In preparation for adding and moving additional objects on the Stage, you’ll rename<br />

and lock the layer. In the next section of the tutorial, you’ll create a new layer.<br />

As you learned in the Understanding Layers lesson, by locking the layer, you ensure that you or<br />

other users don’t make inadvertent changes to objects on the layer.<br />

1 In the Timeline, double-click the Layer 1 name and type Background to rename the layer.<br />

2 Click away from the layer name, then click the padlock icon to lock the layer.<br />

Create and mask vector art<br />

When you draw in <strong>Flash</strong>, you create vector art, which is a mathematical representation of lines,<br />

curves, color, and position. Vector art is resolution-independent; you can rescale the art to any size<br />

or display it at any resolution without losing clarity. Additionally, vector art downloads faster than<br />

comparable bitmap images.<br />

Along with the gradient, the finished file contains background shapes. You’ll use the Oval tool to<br />

create the shapes.<br />

Specifically, in this section you’ll learn how to complete the following tasks:<br />

• Add a layer<br />

• Create and “cut out” shapes<br />

• Mask the layer containing the shapes<br />

To complete this section, you can either continue to work on your mystiletto.fla file, or you can<br />

browse to your <strong>Flash</strong> <strong>MX</strong> application folder and open <strong>Tutorials</strong>/<strong>Flash</strong>Intro/stiletto2.fla. If you do<br />

use the stiletto2.fla file, save the file with a new name in your My_Stiletto folder to maintain an<br />

unadulterated version of the original file.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 21


Add a layer<br />

Rather than create the shapes on the Background layer, you’ll add a new layer on which you can<br />

draw the shapes.<br />

1 To add a new layer, choose Insert > Layer, or click the Insert Layer button. Name the new<br />

layer Shapes.<br />

Insert Layer button<br />

2 In the toolbox, select the Oval tool.<br />

3 In the Property inspector, select Hairline from the Stroke Style pop-up menu. Click the Stroke<br />

Color control. In the color palette, select the gray with a hexadecimal value of 999999.<br />

Remember, you can either enter the hexadecimal value in the hexadecimal text box, or find and<br />

click the color swatch with the same hexadecimal value.<br />

4 If the Color Mixer isn’t open, choose Window > Color Mixer. In the Fill Style pop-up menu,<br />

select Solid. Click the Fill Color control to select it. In the R (red) field, type 109. In the G<br />

(green) and B (blue) text boxes, type 45, then press Enter or Return.<br />

You are specifying the values for the amount of red, green, and blue within a color.<br />

5 In the Timeline, verify that the Shapes layer is selected. On the Stage, constrain the oval to a<br />

circle by pressing Shift as you drag, to draw a circle that extends from the canvas area above the<br />

Stage to the canvas below the Stage.<br />

Note: If you make a mistake, choose Edit > Undo and try again.<br />

22<br />

Chapter 1


6 Select the Arrow tool in the toolbox, then double-click the circle on the Stage to select both the<br />

fill and the stroke.<br />

7 If the Transform panel isn’t open, choose Window > Transform.<br />

8 To expand the Transform panel, click the white arrow in the upper left corner. Select Skew and<br />

type 20.0 in the Skew Horizontally text box, then press Enter or Return.<br />

The circle that you drew changes into a skewed oval.<br />

Create and transform a duplicate shape<br />

You’ll now create and transform a duplicate oval.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 23


1 With the oval fill and stroke still selected on the Stage, choose Edit > Duplicate.<br />

2 In the Property inspector, use the Fill Color control to select black.<br />

3 In the toolbox, select the Free Transform tool.<br />

A guide with handles appears around the duplicate oval.<br />

24<br />

Chapter 1


4 Move the pointer over a corner handle until a diagonal indicator with arrows at both ends<br />

appears. Drag the corner handle inward to make the oval smaller. Verify that the stroke of the<br />

inside oval is not touching the stroke of the outside oval.<br />

5 Move your pointer above the corner handle until the pointer changes into a circular rotation<br />

indicator. Drag the rotation indicator to the left to rotate the oval to the approximate position<br />

shown in the following illustration.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 25


Create a “cut out” with the duplicate<br />

When you create one shape on top of another on the same layer, and the two shapes are different<br />

colors as well as ungrouped, the shape on top “cuts out” the area of the shape underneath. You’ll<br />

delete the duplicate oval to view the cut out effect.<br />

1 With the Free Transform tool guide around the duplicate oval, click anywhere on the Stage or<br />

canvas away from the shapes, then click the fill of the inner oval. Press Delete on your keyboard<br />

to delete the fill.<br />

2 The oval now has an outer and an inner stroke. With the Arrow tool, click the outermost<br />

stroke on the oval to select it, then Shift-click to select the innermost stroke as well. Drag the<br />

strokes slightly to the right of the fill, as shown in the following illustration.<br />

26<br />

Chapter 1


3 Each area of fill color within the area bisected by the stroke now represents a discrete segment<br />

that you can color individually. Select an area of the shape fill, and use the Color Mixer to<br />

change the fill color to a brown shade with an R (red) value of 117, a G (green) value of 78,<br />

and a B (blue) value of 53. If desired, repeat this step to change another fill area to the lighter<br />

shade of brown, as shown in the following illustration:<br />

4 Select the Free Transform tool. Drag around the oval background shapes to select all the<br />

shapes, then drag the right corner handle of the guide to enlarge the shapes, as shown in the<br />

following illustration.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 27


5 Drag the shapes on the Stage so that part of the curve shows on the upper left corner and right<br />

side of the Stage.<br />

Note: As you complete the tutorial, remember to save your file frequently.<br />

Create a mask<br />

The art that you created on the Shapes layer extends beyond the Stage, well into the canvas area.<br />

Although the area on the canvas won’t appear in your published movie, the art beyond the Stage<br />

can be distracting in the authoring environment. While you can erase the part of the shapes that<br />

extend into the canvas, a better solution is to apply a mask over the Stage so that only the area<br />

under the mask—the entire Stage, in this case—remains visible. This way, if you’d like to return<br />

to the shapes to modify them, they will be intact.<br />

1 With the Shapes layer selected, add a new layer to the Timeline and name it Mask.<br />

2 In the toolbox, select the Rectangle tool and draw a rectangle that extends from the upper left<br />

corner of the Stage to the lower right corner.<br />

This rectangle is the shape of your mask. Anything under the rectangle will be visible.<br />

28<br />

Chapter 1


3 Right-click (Windows) or Control-click (Macintosh) the Mask layer name in the Timeline and<br />

choose Mask from the context menu.<br />

The layer is converted to a mask layer, indicated by a down arrow icon. The layer immediately<br />

below it is linked to the mask layer, and its contents show throughout the filled area on the<br />

mask. The masked layer name is indented, and its icon changes to a right-pointing arrow. The<br />

art on the canvas is no longer visible on the Stage.<br />

Mask layers must be locked for the Mask effect to show. To edit the shapes, you can unlock the<br />

Mask and Background Shapes layers. When you finish editing the art, lock the layers again to<br />

invoke masking.<br />

4 Save your file.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 29


Tween bitmap effects within a movie clip<br />

In addition to creating vector art in <strong>Flash</strong>, you can import bitmap images, which use pixels to<br />

display graphics, into your <strong>Flash</strong> movie and apply various color effects. In this section, you’ll<br />

complete the following tasks:<br />

• Import bitmap images<br />

• Modify bitmap compression<br />

• Create and edit a movie clip symbol<br />

• Tween bitmap effects to fade views of the car in and out<br />

To complete this section, you can either continue to work on your mystiletto.fla file, or you can<br />

browse to your <strong>Flash</strong> <strong>MX</strong> application folder and open <strong>Tutorials</strong>/<strong>Flash</strong>Intro/stiletto3.fla. If you do<br />

use the stiletto3.fla file, save the file with a new name in your My_Stiletto folder to maintain an<br />

unadulterated version of the original file.<br />

Import images into the library<br />

When you import a file into <strong>Flash</strong>, you can import it directly into the library.<br />

1 On the Timeline, add a new layer and name it Images.<br />

2 Choose File > Import to Library.<br />

When you select Import to Library rather than Import, the images must be placed on the Stage<br />

before they will appear.<br />

3 Browse to your <strong>Tutorials</strong>/<strong>Flash</strong>Intro/Assets folder within your <strong>Flash</strong> <strong>MX</strong> application folder and<br />

select view1.png, then Shift-click to add view2.png and view3.png to the selection. Click Open.<br />

The three images are now in the library.<br />

Modify bitmap compression<br />

When you import an image, you can check and modify settings that compress the image. While<br />

compressing images reduces the file size of your movie, compression can affect image quality; the<br />

goal is to strike a balance between compression settings and image quality.<br />

1 If the Library panel isn’t open, choose Window > Library. Enlarge the window, if necessary, to<br />

see the three files you imported.<br />

30<br />

Chapter 1


2 Double-click the view1.png file.<br />

JPEG compression is the default selection.<br />

3 In the Compression pop-up menu, select Lossless (PNG/GIF) for higher image quality.<br />

4 To test how the image appears with the new setting, click Test. If necessary, drag the car into<br />

view in the preview window. When you finish previewing the image, click OK.<br />

5 Return to the Library panel. Double-click view2.png and repeat step 3, then click OK.<br />

6 In the Library panel, double-click view3.png and specify Lossless (PNG/GIF), then click OK.<br />

Create a movie clip symbol<br />

In the finished file, three views of the electric car fade in and out in the opening scene. This effect<br />

is achieved by creating a movie clip symbol that has a Timeline independent of the main<br />

Timeline. Next, you tween the alpha transparency between three views of the car to create a fade<br />

in/fade out effect. To begin to create the effect, you’ll create the movie clip.<br />

1 With the Images layer still selected in the Timeline, drag the view1.png object from the Library<br />

panel to the Stage, placing the car within the area where the gradient background is lightest.<br />

2 Choose Insert > Convert to Symbol, or press F8.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 31


3 In the Convert to Symbol dialog box, name the symbol Car Animation. Verify that Movie Clip<br />

is selected and that the center square is selected in the Registration indicator, and click OK.<br />

Bitmaps, like other <strong>Flash</strong> objects, have registration points used for positioning and<br />

transformation. When you align the three views of the car within the movie clip, all three views<br />

should align relative to a center registration point.<br />

Registration point<br />

Edit a symbol<br />

To view the Timeline of the movie clip, you must be in symbol-editing mode. You can open<br />

symbol-editing mode by double-clicking the symbol either on the Stage or in the Library panel.<br />

1 On the Stage, double-click the car to open symbol-editing mode.<br />

The name of the symbol appears above the canvas area, along with a Scene 1 link that returns<br />

you to the main movie.<br />

In symbol-editing mode, you’re now viewing the Timeline for the movie clip rather than the<br />

Timeline for the main movie.<br />

2 Rename Layer 1 View 1 Fade.<br />

3 The car that you see on the Stage is a bitmap image, not a symbol, within the Car Animation<br />

symbol. Make the car a symbol by selecting it on the Stage and pressing F8.<br />

4 In the Convert to Symbol dialog box, name the symbol View 1 Car, then verify that Movie<br />

Clip is selected.<br />

5 Verify that the center square is selected in the Registration indicator and click OK.<br />

6 Scroll horizontally across the Timeline until you get to Frame 105. Select the frame and choose<br />

Insert > Keyframe, or press F6 to add a keyframe.<br />

The Current Frame indicator displays the selected frame.<br />

Current frame<br />

7 Add keyframes to Frames 25 and 35.<br />

32<br />

Chapter 1


8 Add a keyframe to Frame 34, then click anywhere on the layer between Frames 36 and 104,<br />

and press Delete on your keyboard.<br />

An empty keyframe appears in Frame 35, and the car does not appear on the Stage from<br />

frame 35 on.<br />

Note: If you make an error in adding keyframes and want to delete them, select one or more frames and<br />

right-click (Windows) or Control-click (Macintosh), then choose Clear Keyframe from the context menu.<br />

Tween bitmap effects<br />

Creating a bitmap effect tween is similar to creating a straight motion tween: you specify settings for<br />

beginning and ending keyframes, then specify tweening for those frames and the frames in between.<br />

<strong>Flash</strong> creates the transitional animation from the first keyframe in the animation to the last.<br />

1 In the Car Animation Timeline, select Frame 34, then click the View 1 Car on the Stage so<br />

that the Property inspector appears displaying movie clip properties.<br />

2 In the Color pop-up menu of the Property inspector, select Alpha. In the Alpha Amount<br />

pop-up menu, either type 0% in the text box and press Enter or Return, or use the pop-up<br />

slider to select 0%.<br />

Bounding rectangle<br />

3 In the Timeline, select any frame between Frames 25 and 34. In the Property inspector, select<br />

Motion from the Tween pop-up menu.<br />

An arrow with a solid line spans the tweened keyframes. A dashed line between keyframes<br />

indicates the tweening is not implemented correctly, which often occurs when a beginning or<br />

ending keyframe is missing.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 33


Fade in the second car<br />

As the View 1 Car fades out, another view of the car should fade in.<br />

1 Add a new layer to the Car Animation Timeline and name it View 2 Fade.<br />

2 On the View 2 Fade layer, add a keyframe to Frame 25.<br />

3 With the playhead still on Frame 25, drag view2.png from the Library panel to the Stage.<br />

4 If the Info panel isn’t open, choose Window > Info. Verify that the center square is selected in<br />

the Registration indicator, then type 0 in the X coordinate text box and type 0 in the Y<br />

coordinate text box. Press Enter or Return.<br />

The Property inspector also has X and Y text boxes; however, those coordinates are relative to a<br />

registration point in the upper left corner of the movie clip.<br />

5 Select the view2.png on the Stage and press F8 to make it a symbol. In the Convert to Symbol<br />

dialog box, name the symbol View 2 Car. Verify that Movie Clip is selected, and click OK.<br />

6 In the movie clip Property inspector, select Alpha in the Color pop-up menu and type 0% in<br />

the Alpha Amount text box.<br />

7 Add a keyframe to Frame 35 of the View 2 Fade layer.<br />

8 On the Stage, click inside the bounding rectangle of the transparent car. In the movie clip<br />

Property inspector, enter 100% in the Alpha Amount text box.<br />

9 On the View 2 Fade layer, select any frame between Frame 25 and Frame 34. In the Property<br />

inspector, select Motion from the Tween pop-up menu.<br />

34<br />

Chapter 1


Fade out the second car<br />

Now you’ll create the animation that fades out the second car.<br />

1 On the View 2 Fade layer, add a keyframe to Frame 60.<br />

2 On the View 2 Fade layer, add a keyframe to Frame 70, and another keyframe to Frame 69.<br />

3 Select the keyframe in Frame 69 of the View 2 Fade layer. Select the View 2 Car on the Stage<br />

and use the Property inspector to select an alpha transparency of 0%.<br />

4 On the View 2 Fade layer, select any frame between Frames 60 and 68. In the Property<br />

inspector, select Motion from the Tween pop-up menu.<br />

5 Click any frame on the View 2 Fade layer between Frames 71 and 105, and press Delete.<br />

Note: As you complete the tutorial, remember to save your work frequently.<br />

Fade in the third car<br />

As the second car fades out, the third car fades in. You’ll create that animation now.<br />

1 With the View 2 Fade layer selected, add a new layer to Timeline and name it View 3 Fade.<br />

2 On the View 3 Fade layer, add a keyframe to Frame 60.<br />

3 With Frame 60 still selected, drag the view3.png from the Library panel to the Stage. Use the<br />

Info panel (choose Window > Info if the panel is closed) to specify 0 for both the X and Y<br />

coordinates, and to verify the registration point is centered, as you did for the view2.png.<br />

4 Select view3.png on the Stage and press F8 to make it a symbol. In the Convert to Symbol<br />

dialog box, name the symbol View 3 Car. Verify that Movie Clip is selected, and click OK.<br />

5 In the Property inspector, select Alpha in the Color pop-up menu and type 0% in the Alpha<br />

Amount text box.<br />

6 Add a keyframe to Frame 70 of the View 3 Fade layer.<br />

7 On the Stage, select inside the bounding rectangle of the View 3 Car. In the Property inspector,<br />

enter 100% in the Alpha Amount text box.<br />

8 On the View 3 Fade layer, select any frame between Frames 60 and 69. In the Property<br />

inspector, select Motion from the Tween pop-up menu.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 35


Fade out the third car<br />

You’ll now create the animation that fades out the third car.<br />

1 On the View 3 Fade layer, add a keyframe to Frames 95 and 105.<br />

2 With Frame 105 selected in the View 3 Fade layer, select the View 3 Car on the Stage and use<br />

the Property inspector to select an alpha transparency of 0%.<br />

3 On the View 3 Fade layer, select any frame between Frames 95 and 104. In the Property<br />

inspector, select Motion from the Tween pop-up menu.<br />

Fade in the first car<br />

As the third car fades out, the first car must fade in to complete the animation.<br />

1 On the View 1 Fade layer, add a keyframe to Frame 95.<br />

2 With Frame 95 still selected, drag the View 1 Car movie clip (not view1.png) from the Library<br />

panel to the Stage.<br />

3 In the Info panel, type 0 in the X coordinate text box and type 0 in the Y coordinate text box.<br />

Press Enter or Return.<br />

4 In the Property inspector, select Alpha in the Color pop-up menu and enter 0% in the Alpha<br />

Amount text box.<br />

5 Select Frame 104 of the View 1 Fade layer.<br />

6 Click inside the bounding rectangle of the View 1 Car movie clip on the Stage. In the Property<br />

inspector, enter 100% in the Alpha Amount text box.<br />

7 On the View 1 Fade layer, select any frame between Frames 95and 104. In the Property<br />

inspector, select Motion from the Tween pop-up menu.<br />

Note: As you complete the tutorial, remember to save your work frequently.<br />

Test the movie<br />

At any point during authoring, you can test how your movie will play as a SWF file.<br />

1 Save your movie and choose Control > Test Movie.<br />

<strong>Flash</strong> exports a SWF copy of your movie.<br />

In the SWF movie, the animation automatically plays in a continuous loop.<br />

2 When you finish viewing the movie, close the SWF file by clicking its close box. In your <strong>Flash</strong><br />

document, choose Edit > Edit Document or click Scene 1 to return to the main Timeline.<br />

36<br />

Chapter 1


Load dynamic text at runtime<br />

In the lesson Adding and Editing Text, you practiced typing text directly on the Stage. You can<br />

also design your movie to include text from external files. One of the easiest ways to accomplish<br />

this is to use the loadVariables action to load text from a text file into a dynamic text field at<br />

runtime. In the FLA file, you can specify text attributes, such as font style, size, and color, for the<br />

dynamic text field. An advantage of keeping text in external files is that anyone who wants to<br />

modify the text can work with the text file rather than the FLA file.<br />

In this section, you’ll learn how to accomplish the following tasks:<br />

• Import and align a logo<br />

• Create a dynamic text field<br />

• Use the Property inspector to assign a text variable name<br />

• Use the loadVariables action to load text from an external file<br />

To complete this section, you can either continue to work on your mystiletto.fla file, or you can<br />

browse to your <strong>Flash</strong> <strong>MX</strong> application folder and open <strong>Tutorials</strong>/<strong>Flash</strong>Intro/stiletto4.fla. If you do<br />

use the stiletto4.fla file, save the file with a new name in your My_Stiletto folder to maintain an<br />

unadulterated version of the original file.<br />

Import the logo<br />

Before creating the dynamic text field, you’ll import the logo, a Macromedia FreeHand file for<br />

which <strong>Flash</strong> automatically adds a layer on the Timeline.<br />

1 In the Timeline, select the Images layer and add a new layer above it. Name the new layer Copy.<br />

2 With the Copy layer selected, choose File > Import.<br />

Earlier in the tutorial, you imported objects into the library. Now you’ll import the logo so that<br />

it appears on the Stage.<br />

3 Browse within your <strong>Flash</strong> <strong>MX</strong> application folder to the <strong>Tutorials</strong>/<strong>Flash</strong>Intro/Assets folder and<br />

click logo.fh10, then click Open.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 37


4 In the FreeHand Import dialog box, verify that Scenes, Layers, and All are selected. Also verify<br />

that Include Background Layer and Maintain Text Blocks is selected, and then click OK.<br />

5 In the Timeline, <strong>Flash</strong> created a layer named Logo. Drag the Logo name to move the layer<br />

below the Copy layer.<br />

6 You can specify Stage coordinates for the logo. In the Property inspector, with the logo<br />

selected, type 10 in the X text box and 20 in the Y text box. Then press Enter or Return.<br />

7 In the Timeline, lock the Logo layer.<br />

38<br />

Chapter 1


Create a dynamic text field<br />

Now you’ll create a dynamic text field. Instead of typing text into the field, you’ll specify the<br />

variable text that loads into the field at runtime.<br />

1 In the Timeline, select the Copy layer. In the toolbox, select the Text tool. In the Property<br />

inspector, select Dynamic Text from the Text Type pop-up menu.<br />

2 In the Font pop-up menu, select _sans.<br />

_sans is a device font appropriate for small text that appears on multiple computer platforms.<br />

For more information about device fonts, see “Using device fonts (horizontal text only),”<br />

under Help > Using <strong>Flash</strong>.<br />

3 In the Point Size text box, type 12.<br />

4 Click the Text (fill) Color box and select yellow, with a hexadecimal value of FFCC00.<br />

5 In the Line Type pop-up menu, select Multiline, which is for multiple lines of text that will wrap.<br />

Text Type pop-up menu<br />

Font pop-up menu<br />

Point Size text box<br />

Line Type pop-up menu<br />

6 On the Stage, click below the logo. Drag the pointer to create a text field the width of the logo<br />

text and the approximate depth of the vertical line that’s grouped with the logo, as shown in<br />

the following illustration.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 39


7 In the Property inspector, type textField in the Var text box.<br />

The text file that will load into the dynamic text field, as seen in the following illustration,<br />

includes text that names the variable: textField=. When you enter this name in the Var text<br />

box, you are naming the variable that the movie should load.<br />

Use the loadVariables action to load text<br />

The loadVariables action includes a parameter to specify the path to the variable text. The text<br />

is in a file named copy.txt, within your <strong>Tutorials</strong>/<strong>Flash</strong>Intro/Assets folder.<br />

1 In the Timeline, add a new layer and name it Actions. If necessary, drag the Actions layer to<br />

the top of the Timeline.<br />

A good practice is to keep actions on the top layer in a Timeline.<br />

2 If the Actions panel is not open, choose Window > Actions. Enlarge the Actions panel, if<br />

necessary, by clicking the white arrow in the title bar to expand the window, and by dragging<br />

the lower right corner of the panel to view the Actions toolbox and Script pane.<br />

The type of Actions panel that is displayed depends on the object to which you’re adding an<br />

action. If you’ve selected a frame, for example, the Actions panel displays actions for frames. If<br />

you’ve selected a button, the Actions panel displays actions for buttons.<br />

40<br />

Chapter 1


3 Click the control in the upper right corner of the panel title bar to display the options menu.<br />

Verify that Normal Mode, rather than Expert Mode, is selected.<br />

Expert mode offers features useful to those experienced with ActionScript. In normal mode,<br />

parameter fields and controls guide you in creating ActionScript.<br />

Options menu control<br />

Actions toolbox<br />

Script pane<br />

4 In the Actions toolbox, choose Actions > Browser/Network, then double-click loadVariables.<br />

The ActionScript is added to the Script pane. Parameters for the action appear above the<br />

Script pane.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 41


5 In the URL text box, type the path to the text file: ../assets/copy.txt.<br />

Test your movie<br />

• Save your movie, then choose Control > Test movie.<br />

You can also press Control+Enter (Windows) or Command+Return (Macintosh).<br />

Add animation and navigation to buttons<br />

When you specify that a new symbol is a button, <strong>Flash</strong> creates the Timeline for the button states.<br />

In the Creating Buttons lesson, you learned how to change the fill color of a shape within a<br />

button state. In this section, you’ll learn more about modifying buttons, including adding<br />

animation to a button.<br />

Specifically, in this section you’ll learn how to complete the following tasks:<br />

• Import a library from another FLA file<br />

• Align buttons<br />

• Add animation to a button state<br />

• Add navigation to a button to link to a Web site<br />

• Use the Enable Simple Buttons feature<br />

• Add button navigation<br />

To complete this section, you can either continue to work on your mystiletto.fla file, or you can<br />

browse to your <strong>Flash</strong> <strong>MX</strong> application folder and open <strong>Tutorials</strong>/<strong>Flash</strong>Intro/stiletto5.fla. If you do<br />

use the stiletto5.fla file, save the file with a new name in your My_Stiletto folder to maintain an<br />

unadulterated version of the original file.<br />

42<br />

Chapter 1


Import the library of another FLA file<br />

The buttons that you’ll use in your movie reside in the library of another FLA file. To use the<br />

buttons, you open the FLA file containing the buttons as a library.<br />

1 With your Library panel open, choose File > Open as Library. Browse within your <strong>Flash</strong> <strong>MX</strong><br />

application folder to the <strong>Tutorials</strong>/<strong>Flash</strong>Intro/Assets folder and double-click buttons.fla.<br />

The library for the buttons.fla file appears in addition to the library for your document.<br />

Align buttons<br />

You can align the three buttons along horizontal and vertical axes using the Align panel.<br />

1 In the Timeline, with the Copy layer selected, add a new layer and name it Buttons. Lock all<br />

the layers except the Buttons layer.<br />

2 In the Stage View pop-up menu, on the right above the Stage, enter 150% to enlarge your view<br />

of the Stage. Then scroll to the lower right side of the Stage.<br />

3 Drag Button 1 from the buttons.fla Library panel and place it under the lower right corner of<br />

the dynamic text field.<br />

When you drag a button from the buttons.fla Library panel, the button becomes part of the<br />

library for your document.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 43


4 Drag Button 2 and Button 3 from the buttons.fla Library panel, placing them to the left of<br />

Button 1. Use the approximate spacing shown in the following illustration:<br />

5 With the Arrow tool, drag to select all three buttons.<br />

6 To open the Align panel, choose Window > Align. Verify that To Stage is not selected. You do<br />

not want to align the buttons relative to the Stage. Click Align Vertical Center, and then click<br />

Distribute Horizontal Center.<br />

Align Vertical Center<br />

To Stage<br />

Distribute Horizontal Center<br />

The buttons align on the Stage.<br />

Enable simple buttons<br />

When the Enable simple buttons feature is active, you can hear the sounds included with Buttons<br />

2 and 3, and you can view the colors used for the button states. More complex button design,<br />

such as animation, does not play.<br />

1 Choose Control > Enable Simple Buttons, then roll over and click each button.<br />

The right button, Button 1, is not finished. You will modify that button next.<br />

2 When you finish testing the buttons, choose Control > Enable Simple Buttons to deselect<br />

that feature.<br />

44<br />

Chapter 1


Modify a button state<br />

You’ll create a movie clip within the Over state of Button 1, then create a shape tween in the<br />

movie clip. The shape tween creates an effect that changes the color from gray to red.<br />

1 On the Stage, double-click the right button, Button 1, to open symbol-editing mode.<br />

2 In the Button 1 Timeline, hide all layers except the Color layer. In the Color layer, select the<br />

Over keyframe.<br />

3 On the Stage, select the black oval shape for the right button. Press F8 to make the oval a<br />

symbol. In the Convert to Symbol dialog box, name the symbol Button Animation. Select<br />

Movie Clip, and click OK.<br />

4 On the Stage, double-click the Button Animation symbol to open symbol-editing mode.<br />

5 Rename Layer 1 Color Change, and add a keyframe to Frame 15.<br />

6 With the playhead still on Frame 15, select the button shape on Stage and choose a bright<br />

shade of red from the Fill Color pop-up menu in the toolbox.<br />

7 In the Timeline, click any frame between Frames 1 and 13. In the Property inspector, select<br />

Shape from the Tween pop-up menu.<br />

Drag the playhead from frames 1 to 15 to see the color change.<br />

Add actions to buttons<br />

When the user clicks the button and the tweened animation plays, you want the playhead to<br />

move to the end of the Button Animation Timeline, then stop. You use ActionScript, the <strong>Flash</strong><br />

scripting language, to control playhead movement in a Timeline.<br />

1 Add a new layer to the Button Animation Timeline and name it Actions.<br />

2 On the Actions layer, add a keyframe to Frame 15.<br />

3 If the Actions panel is not open, choose Window > Actions. Enlarge the panel, if necessary, to<br />

view both the Actions toolbox and the Script pane.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 45


4 With Frame 15 of the Actions layer selected, go to the Actions > Movie Control category of the<br />

Actions toolbox and double-click stop.<br />

The stop action lets you specify that the playhead will stop when it reaches Frame 15.<br />

In the Button Animation Timeline, Frame 15 of the Actions layer now displays a small a,<br />

which indicates that an action is attached to that frame.<br />

Note: As you complete the tutorial, remember to save your work frequently.<br />

Add button navigation<br />

You use the getURL action to add navigation to a button that opens a Web site.<br />

1 Choose Edit > Edit Document or click Scene 1 to return to the main movie.<br />

2 On the Stage, click Button 1, the right button.<br />

3 In the Actions panel, choose Actions > Browser/Network and double-click getURL.<br />

4 In the URL text box, type any complete URL, such as http://www.macromedia.com.<br />

46<br />

Chapter 1


5 In the Window pop-up menu, select _blank to launch a new browser window when the user<br />

clicks Button 1.<br />

6 Save your file, then choose Control > Test movie. Click Button 1 to go to the Web site you<br />

specified in step 4.<br />

7 Close the browser and the SWF file, and then return to the <strong>Flash</strong> authoring environment. If<br />

desired, you can select Button 2 on the Stage and repeat steps 3 through 7 to link it to a<br />

different Web site, then repeat the steps for Button 3. When you finish linking the buttons,<br />

close the Actions panel.<br />

Add streaming and event sounds<br />

When a movie is downloading from an Internet source, a streaming sound can begin to play as<br />

soon as the beginning of the sound file has downloaded. Such sounds are especially suited for<br />

continuous background sounds.<br />

Event sounds must download completely and load into RAM before playing; event sounds are<br />

useful for buttons. In this section, you’ll learn how to accomplish the following tasks:<br />

• Add a streaming sound to your movie<br />

• Add an event sound to a button<br />

To complete this section, you can either continue to work on your mystiletto.fla file, or you can<br />

browse to your <strong>Flash</strong> <strong>MX</strong> application folder and open <strong>Tutorials</strong>/<strong>Flash</strong>Intro/stiletto6.fla. If you do<br />

use the stiletto6.fla file, save the file with a new name in your My_Stiletto folder to maintain an<br />

unadulterated version of the original file.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 47


Add a streaming sound<br />

You can include sound in your movie by dragging the sound to the Stage. You’ll add background<br />

music that streams and plays for a specified number of times.<br />

1 In the Timeline, with the Buttons layer selected, add a new layer and name it Sounds.<br />

2 Choose File > Import. Within your <strong>Flash</strong> <strong>MX</strong> application folder, browse to <strong>Tutorials</strong>/<br />

<strong>Flash</strong>Intro/Assets and click track1.mp3. Control-click (Windows) or Command-click<br />

(Macintosh) to add ping.mp3 to the selection, then click Open.<br />

The files are imported into the library.<br />

3 With the Sounds layer selected, drag the track1.mp3 sound from the Library panel to the Stage.<br />

In the Timeline, a small representation of sound waves appears in the frame.<br />

4 In the Timeline, select the first frame of the Sounds layer. In the Property inspector, type 999<br />

in the Loop text box to specify the number of times the sound can play continuously.<br />

Test the movie<br />

1 Save your file, then choose Control > Test Movie to hear the sound.<br />

2 When you finish playing the movie, click the movie’s close box.<br />

Add an event sound to a button<br />

In addition to dragging a sound to the Stage, you can select a sound from the Property inspector.<br />

You will use this method to add an event sound to a button.<br />

As you learned in the Creating Buttons lesson, when you create a button symbol, <strong>Flash</strong> creates<br />

frames for the different button states in relation to the mouse pointer. The Over frame, for<br />

example, represents the button’s state when the pointer is over the button. Other button frames/<br />

states are Up, Down, and Hit.<br />

Now you’ll add an event sound to a button, which causes the sound to play during the Over state.<br />

Because you’re adding the sound to the button symbol in the library, not just to an instance of the<br />

symbol, the sound will play for each instance of the button.<br />

1 In the Library panel, double-click the Button 1 instance to open symbol-editing mode.<br />

2 In the Timeline for Button 1, add a new layer and name the new layer Sound.<br />

3 Select the Over frame (Frame 2) of the Sound layer and choose Insert > Keyframe or press F6.<br />

4 To define the sound properties, click Frame 2 of the Sound layer. In the Property inspector,<br />

select Ping.mp3 from the Sound pop-up menu. Verify that Event is selected in the Sync<br />

pop-up menu.<br />

5 Save your document and choose Control > Test Movie to hear the button sounds. When you<br />

finish viewing the SWF file, close its window to return to the document.<br />

48<br />

Chapter 1


Organize your Library panel<br />

You currently have quite a few assets in your Library panel. To keep these assets organized, easy to<br />

find, and categorized by type, you’ll create folders, then move the assets into the folders.<br />

Tip: Keeping your library panel organized is a good practice for any movie that you author, especially because others<br />

working on the same file can then locate assets easily.<br />

1 If the Library panel is not open, choose Window > Library.<br />

2 Expand and enlarge the window, as necessary, to view all the assets in the Library panel. At the<br />

bottom of the Library panel, click the New Folder button four times, to create four new folders.<br />

3 Double-click the name of untitled folder 1, and rename it Car Animation Movie Clips. Then<br />

press Enter or Return.<br />

4 Rename the other three folders Sounds, Artwork, and Buttons.<br />

5 Drag View 1 Car, View 2 Car, View 3 Car, and Car Animation to the Car Animation Movie<br />

Clips folder.<br />

6 Drag ping.mp3 and track1.mp3 to the Sounds folder.<br />

7 Drag view1.png, view2.png, and view3.png to the Artwork folder.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 49


8 Drag Button 1, Button 2, and Button 3 to the Buttons folder. With the Buttons folder<br />

selected, click New Folder again to create a subfolder with the Buttons folder.<br />

9 Name the new folder Button Movie Clips, then drag the remaining button movie clip assets to<br />

this folder.<br />

10 Close the Library panel and save your document.<br />

50<br />

Chapter 1


Test download performance and publish the movie<br />

To complete your document, you will use the Publish command to create a Web-compatible<br />

movie with the SWF extension.<br />

If you use the Publish command with the default settings, <strong>Flash</strong> prepares your file for the Web.<br />

<strong>Flash</strong> will Publish the SWF and create an HTML file with the tags necessary to display the SWF.<br />

Once you define the necessary Publish Settings options, you can repeatedly export to all selected<br />

formats at once by simply choosing File > Publish. <strong>Flash</strong> stores the publish settings you specify<br />

with the document, so each movie can have its own settings.<br />

In this section, you’ll learn how to complete the following tasks:<br />

• Use the Bandwidth Profiler to test movie download performance<br />

• Publish your movie in one step<br />

• Review and modify publish settings<br />

• View your movie in a Web browser<br />

To complete this section, you can either continue to work on your mystiletto.fla file, or you can<br />

browse to your <strong>Flash</strong> <strong>MX</strong> application folder and open <strong>Tutorials</strong>/<strong>Flash</strong>Intro/stiletto7.fla. If you do<br />

use the stiletto7.fla file, save the file with a new name in your My_Stiletto folder to maintain an<br />

unadulterated version of the original file.<br />

Test movie download performance<br />

For a <strong>Flash</strong> movie to play correctly over the Internet, a frame must download before the movie<br />

reaches that frame. If the movie reaches a frame that hasn’t downloaded yet, it pauses until the<br />

data arrives. The low bandwidth of <strong>Flash</strong> files promotes fast downloads.<br />

You can use the Bandwidth Profiler to test your movie and identify where pauses might occur.<br />

The Bandwidth Profiler graphically shows how much data is sent from each frame in the movie,<br />

according to the selected modem speed.<br />

1 Save your document and choose Control > Test Movie.<br />

2 From the Debug menu, select a modem speed to determine the download rate that <strong>Flash</strong><br />

will simulate.<br />

You can also choose Customize to enter a download rate.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 51


3 Choose View > Bandwidth Profiler to see the SWF with a download performance chart.<br />

The shaded bar represents the first and only frame in your main movie. Movies with multiple<br />

frames will have multiple shaded bars. The height of the bar represents the frame’s size in bytes<br />

and kilobytes. Bars that extend above the red line, especially if the bar represents a frame other<br />

than the first frame, indicate there could be delays in movie playback. You can optimize your<br />

movie for faster downloads. For details, see “Optimizing movies” under Help > Using <strong>Flash</strong>.<br />

4 When you finish viewing the Bandwidth Profiler, choose View > Bandwidth Profiler to<br />

deselect it. Close the SWF window to return to the authoring environment.<br />

Use the Publish command<br />

You can publish your <strong>Flash</strong> document for Web playback in one step.<br />

• With your document saved, choose File > Publish.<br />

<strong>Flash</strong> publishes your movie by creating a SWF file, and possibly additional files, based on the<br />

attributes in the Publish Settings dialog box. You’ll find the published files, by default, in the<br />

same folder where you saved your FLA.<br />

52<br />

Chapter 1


View publish settings<br />

Using the Publish Settings dialog box, it’s easy to reconfigure the way your file publishes.<br />

1 To view your publish settings, choose File > Publish Settings.<br />

<strong>Flash</strong> is configured, by default, to create a supporting HTML file that displays the <strong>Flash</strong> movie.<br />

When you select a format that requires additional settings, a new tab appears.<br />

2 On the Formats tab, verify that <strong>Flash</strong> (.swf) and HTML (.html) are selected. Click the <strong>Flash</strong> tab.<br />

By default, the movie publishes for the <strong>Flash</strong> Player. The publishing process also applies movie<br />

and JPEG compression.<br />

3 Click the HTML tab.<br />

By default, the publishing process creates an HTML document that inserts your SWF file in a<br />

browser window. Settings on the HTML tab of the Publish Settings dialog box determine how<br />

the movie appears in the browser.<br />

Change publish settings<br />

By default, <strong>Flash</strong> gives the SWF file the same name as the FLA file. You can tell <strong>Flash</strong> to change<br />

the name.<br />

1 On the Formats tab of the Publish Settings dialog box, deselect Use Default Names.<br />

2 In the HTML (.html) text box, select the existing text and type a new name, such as<br />

stilettoElectric.html. Then click Publish. When the Publishing status window closes, click OK<br />

in the Publish Settings dialog box.<br />

Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial 53


View your published movie in a browser<br />

You can view the HTML file and SWF movie, which you just published, in your browser.<br />

1 Open your browser, then open the HTML file that you created.<br />

By default, the HTML file is in the same folder as your FLA file.<br />

When you open the HTML file, the SWF movie plays within your browser.<br />

2 In your browser, you can use a command such as View > Page Source or View > Source<br />

to view the HTML.<br />

OBJECT and EMBED tags ensure that the SWF movie is displayed within the browser.<br />

The next steps<br />

By completing all eight sections of the tutorial, you’ve learned much about creating <strong>Flash</strong> movies,<br />

including how to complete the following tasks:<br />

• Analyze a completed movie<br />

• Define document properties and create a gradient<br />

• Create and mask vector art<br />

• Tween bitmap effects within a movie clip<br />

• Load dynamic text<br />

• Modify buttons and add navigation<br />

• Add streaming and event sounds<br />

• Test and publish a movie<br />

Continue learning more about <strong>Flash</strong> capabilities by taking the Introduction to ActionScript<br />

Tutorial under Help > <strong>Tutorials</strong>. Designed for ActionScript novices, the tutorial introduces you to<br />

scripting concepts while allowing you to build a jigsaw puzzle with actions. Additionally, you can<br />

search for articles and Tech Notes about <strong>Flash</strong> <strong>MX</strong> in the Macromedia award-winning Support<br />

Center. To access the site, go to www.macromedia.com and click Support.<br />

54<br />

Chapter 1


CHAPTER 2<br />

Introduction to ActionScript Tutorial<br />

ActionScript is the scripting language of Macromedia <strong>Flash</strong> <strong>MX</strong>. A scripting language is a way to<br />

communicate with a program; you can use it to tell <strong>Flash</strong> what to do and to ask <strong>Flash</strong> what is<br />

happening as a movie runs. This two-way communication lets you create interactive movies. In<br />

this tutorial, you will examine the tasks involved in creating an interactive jigsaw puzzle.<br />

This tutorial is designed for <strong>Flash</strong> users who are ActionScript beginners but who want to work<br />

toward advanced abilities. You should already be familiar with basic actions and know how to<br />

assign them in the Actions panel. To get the most out of this tutorial, you should first complete<br />

the Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial, under Help > <strong>Tutorials</strong>. You should also be comfortable<br />

with the concepts presented in “Writing Scripts with ActionScript” and “Creating Interaction<br />

with ActionScript,” under Help > Using <strong>Flash</strong>.<br />

This tutorial takes approximately one hour to complete, depending upon your experience, and<br />

will teach you how to do the following tasks:<br />

• Initialize the movie<br />

• Save and retrieve information<br />

• Display information in a dynamic text box<br />

• Write an expression<br />

• Control the flow of the movie<br />

• Create commands and reuse code<br />

• Use a built-in object<br />

• Test the movie<br />

55


View a completed movie<br />

Before you begin work on your own movie, view a completed version of this tutorial to get an<br />

idea of what you’ll create. Additionally, the completed tutorial lets you examine the Timeline,<br />

Movie Explorer, Stage, and Actions panel to understand authoring practices.<br />

1 Within your <strong>Flash</strong> <strong>MX</strong> application folder, browse to <strong>Tutorials</strong>/ActionScript/Finished.<br />

Double-click puzzle.swf to open the completed movie in the stand-alone <strong>Flash</strong> Player.<br />

2 In the puzzle.swf movie, click the OK button.<br />

The puzzle pieces scramble.<br />

3 Click all the Show/Hide buttons.<br />

Notice how the different patterns and piece numbers are displayed to guide you in completing<br />

the puzzle.<br />

4 Click a puzzle piece and drag it to the solution area.<br />

The piece snaps into place.<br />

5 Shift-click a puzzle piece.<br />

The piece number appears in the circle under the solution area. You can match the piece<br />

number to its location in the piece number guide if you get stuck.<br />

6 Alt-click (Windows) or Option-click (Macintosh) a puzzle piece.<br />

The piece rotates clockwise.<br />

7 When you finish viewing the SWF file, you can either close the window or leave it open to<br />

serve as a reference.<br />

56<br />

Chapter 2


Analyze the puzzle.fla file<br />

It’s helpful to analyze the completed FLA file to determine how the author put it together and<br />

where the ActionScript elements are located.<br />

1 In <strong>Flash</strong>, choose File > Open. Within your <strong>Flash</strong> <strong>MX</strong> application folder, browse to <strong>Tutorials</strong>/<br />

ActionScript/Finished and open the puzzle.fla file.<br />

You now see the completed tutorial movie in the authoring environment.<br />

2 To see all the contents on the Stage, choose View > Magnification > Show Frame.<br />

The movie contains only one frame, displayed in the main Timeline of the puzzle.fla file. You<br />

will use ActionScript to show and hide the various dialog boxes and pattern guides that appear<br />

in the puzzle.<br />

3 To resize the Timeline and Stage, drag the bar that separates the Stage from the Timeline up<br />

and down. Scroll through the Timeline to see how the layers are organized.<br />

Move this bar to resize the Timeline.<br />

4 To see the dialog boxes and guides on the Stage in the authoring environment, click the red X<br />

in the Eye column to the right of a layer’s name. A red X indicates a hidden layer.<br />

You click in the Lock column to lock a layer, which prevents it from being selected. This is<br />

useful if you are selecting an item on the Stage that is underneath an item in another layer. The<br />

Outline column, indicated by a square above the column, turns on outlines of all the elements<br />

in a layer; this can make it easier to see shape edges and can cause <strong>Flash</strong> to work faster.<br />

Introduction to ActionScript Tutorial 57


5 Select Frame 1 of the Actions layer.<br />

Frame 1 has a lowercase a, which indicates actions are associated with the frame.<br />

To add an ActionScript element to a movie, you must assign it to either a button, a frame, or a<br />

movie clip. Frame scripts are indicated by a lowercase a on a frame in the Timeline. To locate<br />

button and movie clip scripts, do one of the following:<br />

• Open the Actions panel and select a script from the Jump bar—the pop-up list under the<br />

Actions panel title bar.<br />

• Select buttons and movie clips on the Stage with the Actions panel open.<br />

• Use the filtering buttons or the Find text box to search for the scripts in the Movie Explorer.<br />

6 If you used the Movie Explorer in the previous step and did not open the Actions panel, open<br />

the Actions panel now (choose Window > Actions).<br />

Expand the panel, if necessary, to see the actions attached to the frame.<br />

The Actions panel has two modes, normal and expert. This tutorial explains how to add<br />

actions in normal mode.<br />

View actions in the Movie Explorer<br />

1 To locate all of the actions in the movie, use the Movie Explorer. If it’s not open, select<br />

Window > Movie Explorer.<br />

In the Movie Explorer, deselect all the filtering buttons except the ActionScript button. In<br />

addition to the actions in Frame 1 of the Actions layer, actions are also included in each of the<br />

Show/Hide buttons, the buttons in the various dialogs boxes that appear, and each puzzle piece.<br />

2 Select File > Close to close the puzzle.fla movie when you’re finished. Do not save changes to<br />

the finished file.<br />

58<br />

Chapter 2


Initialize the movie<br />

All movies have an initial state. This shows how a movie looks before it runs and anyone interacts<br />

with it. Sometimes you must set variables and movie clip properties to establish this first state. For<br />

example, in the puzzle.fla file, certain dialog boxes and pattern guides must be hidden in the<br />

initial state.<br />

Each movie clip in a <strong>Flash</strong> movie has a set of qualities, or properties, that you can manipulate with<br />

ActionScript. Each of those properties is identified by a name preceded by an underscore (_)<br />

character. For example, each movie clip has an _xscale property, a _yscale property, and a<br />

_rotation property, among others.<br />

ActionScript uses variables to store information. For example, the variable myName might hold the<br />

value "Jody Singer". You can learn more about variables in the section “Save and retrieve<br />

information” on page 64.<br />

You initialize properties and variables in the first frame of a movie. You can assign a frame action in<br />

the Timeline, or attach an object action to a movie clip. In the puzzle movie, the properties of the<br />

pattern guide and dialog box movie clips are initialized in the first frame of the main Timeline.<br />

Open the starting file<br />

Now you’re ready to create your own version of the tutorial movie.<br />

1 Choose File > Open.<br />

2 In the <strong>Flash</strong> <strong>MX</strong> application folder, browse to <strong>Tutorials</strong>/ActionScript/My_Puzzle and open<br />

mypuzzle.fla.<br />

3 If you receive a font substitution message, click Use Default.<br />

You see a partially completed tutorial movie. The movie may look finished because all the<br />

symbols are in place on the Stage. However, you’ll still need to add quite a few scripts to make<br />

the movie interactive.<br />

4 Choose File > Save As and save the file with a new and sequential name, such as mypuzzle2.fla,<br />

in the same folder as mypuzzle.fla.<br />

Making a copy of the file allows you or another user to complete the tutorial again using the<br />

original mypuzzle.fla file. Additionally, if you regularly save your file with a new and sequential<br />

name, you can revert to an earlier file if you make an error that you’re not able to resolve in<br />

your current file.<br />

Introduction to ActionScript Tutorial 59


Set movie clip properties<br />

The puzzle.fla movie has three dialog boxes: one alerts you when the puzzle is completed, and the<br />

other two ask if you want to scramble the puzzle pieces. Additionally, several patterns and guides<br />

overlay the solution area to help users solve the puzzle. Each of these dialog boxes, patterns, and<br />

guides is a movie clip.<br />

To initialize the movie, you must hide several of the movie clips so that only the start dialog box<br />

and the puzzle pieces are showing. You’ll do this by setting their _visible properties to false.<br />

1 Select Frame 1 in the Actions layer. If the Actions panel isn’t open, choose Window > Actions.<br />

The Actions panel shows actions associated with the selected frame. Text after double slashes<br />

(//) is commented text, which offers information helpful in understanding the scripts.<br />

2 Click the pop-up menu in the upper right corner of the Actions panel title bar. Verify that the<br />

options Normal Mode and View Line Numbers are selected.<br />

3 Click the pop-up menu in the Actions panel title bar again and select Auto Format Options. In<br />

the dialog box that appears, verify that no options are selected. (If an option is selected, deselect it).<br />

Note: This tutorial refers to specific line numbers in the ActionScript. If auto format options are selected, the line<br />

numbers in your tutorial FLA file might not match the line numbers referred to in the tutorial.<br />

4 In the Script pane, click line 4 to select the commented code that reads // ENTER code here.<br />

5 From the Actions > Miscellaneous Actions category in the Actions toolbox on the left,<br />

double-click the evaluate action to add an empty line of code ending with a semicolon.<br />

(If the Expert Mode Warning dialog box appears, click OK).<br />

A semicolon (;) in an ActionScript statement is like a period (.) in an ordinary sentence.<br />

60<br />

Chapter 2


6 With the insertion point in the Expression text box of the Actions panel, click the Insert Target<br />

Path button.<br />

The Insert Target Path dialog box appears.<br />

7 Verify that Dots, meaning dots notation, and Absolute, meaning absolute path, are selected.<br />

In the dialog box, you see a list of movie clips from which you can select.<br />

8 Select the edges movie clip from the movie clip tree, then click OK.<br />

The following code appears in the Expression text box:<br />

_root.edges<br />

A target path tells ActionScript the location of a movie clip within the overall structure of a<br />

<strong>Flash</strong> movie. The _root property refers to the main Timeline and the edges movie clip lives<br />

on the Stage of the main Timeline. Any target path that begins with _root is called an absolute<br />

path because it gives the complete path to a movie clip from the main Timeline.<br />

9 With the insertion point after _root.edges, enter ._visible = false in the Expression text box.<br />

This line of code makes the movie clip invisible on the Stage.<br />

You can type the code manually, or you can choose ActionScript items from the Properties and<br />

Operators folders in the Actions toolbox.<br />

If you make an error entering an action and decide you’d like to delete it, select the action in<br />

the Script pane and click the Minus (-) button in the Actions panel.<br />

10 In the Actions toolbox, again double-click the evaluate action to add an empty line of code<br />

ending with a semicolon. Repeat steps 5 and 6, then choose the pattern movie clip in the<br />

Insert Target Path dialog box. Repeat Step 8, again typing ._visible = false in the Expression<br />

text box.<br />

Introduction to ActionScript Tutorial 61


11 Continue to repeat steps 4 through 8, choosing the image, piecenumbers, scramblebutton,<br />

areYouSure, and congrats movie clips in the Insert Target Path dialog box, and typing<br />

._visible = false for each movie clip.When you finish, your script should appear as follows:<br />

12 Choose File > Save As and enter a new filename. Use a consecutive naming scheme, such as<br />

mypuzzle3.fla, so you can revert to earlier versions of the file, if necessary.<br />

Use the Reference panel<br />

During authoring, if you’d like additional information about the ActionScript that you enter, you<br />

can select the action in the Actions toolbox or Script pane, then click the Reference button. The<br />

Reference panel, a help system organized similarly to the Actions panel, displays information<br />

about the selected action.<br />

62<br />

Chapter 2


Test your syntax<br />

ActionScript, like written language, depends on correct syntax. If the syntax is incorrect, the<br />

action will not execute correctly. <strong>Flash</strong> offers a variety of ways for you to test your syntax.<br />

1 Click the options menu in the upper right corner of the Actions panel title bar and choose<br />

Check Syntax.<br />

If the syntax is correct, a message appears stating that the script contains no errors.<br />

If the syntax is incorrect, a message appears stating the script contains errors; the Output<br />

window opens and displays information about the error.<br />

2 Click OK to close the syntax message.<br />

In normal mode, ActionScript syntax errors appear highlighted in red in the Script pane. If you<br />

move your mouse pointer over the error, a tooltip displays the error message. Syntax error<br />

messages also appear highlighted along the bottom status area of the Actions panel.<br />

Additionally, as you learned in the Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial, you can choose Control ><br />

Test Movie throughout authoring to test if your movie plays as expected.<br />

Introduction to ActionScript Tutorial 63


Save and retrieve information<br />

To create a complex interactive <strong>Flash</strong> movie, you need a way for <strong>Flash</strong> to keep track of<br />

information and user activity: buttons that have been pressed, a user’s name, a score, or what<br />

sections a user has visited. ActionScript uses variables to store pieces of information that you can<br />

retrieve and use again. You can declare a variable in a script on any Timeline and use it in any<br />

other Timeline in the same movie. You must write a target path to a variable in order to use the<br />

variable in a script, just as you must write a target path to use a movie clip in a script.<br />

In the puzzle.fla file, ActionScript uses the dialog variable to keep track of whether or not a<br />

dialog box is visible. When a dialog box appears, the dialog variable is set to true; when a user<br />

clicks a button on a dialog box, the dialog variable is set to false. This variable doesn’t affect the<br />

visibility of the dialog boxes themselves, it is simply a container that holds information that you<br />

can use in scripts throughout the movie. In the puzzle.fla file, if dialog is set to true, a user<br />

cannot move a puzzle piece.<br />

Declare a variable and assign it a value<br />

When you need a variable, you must name it, or declare it. You must also assign it a value. You can<br />

either do both things at once, or you may declare a variable in one statement and then assign it a<br />

value in a later statement.<br />

ActionScript uses three types of variables: local variables, global variables, and Timeline variables.<br />

You can use the var action inside a block of code (designated by curly brackets {}) to create a<br />

local variable, which disappears when the code block finishes running. You can use the set<br />

variable action to create a Timeline variable attached to the Timeline of a movie clip, which can<br />

be used in any script in the document. For more information about variables, see “Understanding<br />

the ActionScript Language” under Help > Using <strong>Flash</strong>.<br />

The puzzle.fla file uses the var action and the set variable action depending on the situation.<br />

When a variable is only needed within a block of code, the var action is used. The dialog<br />

variable is set and assigned using the set variable action.<br />

Now you’ll declare and assign a value to the dialog variable:<br />

1 Select File > Open and choose the version of mypuzzle.fla that you last saved.<br />

Note: You can also browse to your <strong>Flash</strong> <strong>MX</strong> application folder and open <strong>Tutorials</strong>/ActionScript/Finished/<br />

puzzle2.fla. If you do use the puzzle2.fla file, save the file with a new name in your My_Puzzle folder to maintain<br />

an unadulterated version of the original file.<br />

2 Select Frame 1 of the Actions layer. If the Actions panel isn’t open, choose Window > Actions.<br />

3 In the Script pane of the Actions panel, select line 11, which is the last line of code in the<br />

Initialize section. In the Actions toolbox, choose Actions > Variables and double-click the set<br />

variable action.<br />

4 Type dialog in the Variable text box.<br />

64<br />

Chapter 2


5 Type true in the Value text box. Select Expression, to the right of the Value text box.<br />

By selecting Expression, you are telling <strong>Flash</strong> that true is not a literal string of characters.<br />

In the movie’s initial state, a dialog box is visible on the Stage. Therefore, the dialog variable<br />

must be set to true at the start of the movie—otherwise, a user can move the puzzle pieces<br />

before they are scrambled.<br />

6 Choose File > Save As and enter a new filename. Use a consecutive naming scheme so you can<br />

revert to earlier versions of the file, if necessary.<br />

Display information in a dynamic text box<br />

Dynamic text boxes can display changing content in a <strong>Flash</strong> movie. You use the Property<br />

inspector to create a dynamic text box and assign it a variable name. The value of the variable is<br />

displayed in the text field.<br />

In the puzzle.fla file, a dynamic text box displays puzzle piece numbers when a user Shift-clicks a<br />

piece. Now you’ll assign a variable name for the dynamic text box.<br />

1 If necessary, choose File > Open and choose the version of the mypuzzle.fla file that you last saved.<br />

Note: You can also browse to your <strong>Flash</strong> <strong>MX</strong> application folder and open <strong>Tutorials</strong>/ActionScript/Finished/<br />

puzzle3.fla. If you do use the puzzle3.fla file, save the file with a new name in your My_Puzzle folder to maintain<br />

an unadulterated version of the original file.<br />

2 In the Timeline, unlock the Piece numbers guide layer if it is locked.<br />

Introduction to ActionScript Tutorial 65


3 Double-click the Piece number circle movie clip on the Stage under the lower right corner of<br />

the puzzle solution area.<br />

Piece number circle movie clip<br />

This opens the Piece number circle in symbol-editing mode.<br />

4 Select the Text layer in the Timeline. On the Stage, click the center of the Piece number circle<br />

to select the text field.<br />

5 If the Property inspector is not open, choose Window > Properties. In the Property inspector,<br />

select Dynamic Text from the Text Type pop-up menu.<br />

6 In the Line Type pop-up menu, verify that Single Line is selected.<br />

66<br />

Chapter 2


7 Type _root.pieceNumber in the Var text box and press Enter or Return.<br />

All variables, like functions and movie clips, must be referenced by their paths. The<br />

pieceNumber variable is declared and updated in the RotateDisplayOrDrag function on the<br />

main Timeline, but the variable text box is in the Piece number circle Timeline. When you<br />

enter the full path to the pieceNumber variable, the value updates and displays in the text field<br />

on the Stage whenever the variable’s value changes on the main Timeline.<br />

8 Either choose Edit > Edit Document, click the Back button, or click Scene 1 to return to the<br />

main Timeline.<br />

9 Choose File > Save As and enter a new filename. Use a consecutive naming scheme so you can<br />

revert to earlier versions of the file if necessary.<br />

Write an expression<br />

If you’ve added two numbers in a math equation, you’ve used an operator. An operator is a symbol<br />

that performs a task, or operation, on a piece, or pieces, of data, or operands. For example, in the<br />

expression 2 + 2, the plus sign (+) is the operator and each number is an operand.<br />

An expression is any ActionScript code that can be evaluated to produce a single value. For<br />

example, the code myAge + 17 is an expression because when the code runs, ActionScript looks<br />

up the value of the myAge variable, adds it to the number 17, and produces a new single value. If<br />

the value of myAge is 47, the new value would be 64.<br />

Operators allow you to take the information you collect and store in variables and manipulate it<br />

in expressions to create or determine other values. For example, you may know that a user has<br />

dropped a puzzle piece onto the solution area, but how do you determine if the piece is in the<br />

correct place? And if the piece is in the correct place, how do you determine if the puzzle has been<br />

solved? To examine expressions built with arithmetic operators in such a scenario, select Frame 1<br />

of the main Timeline, open the Actions panel, and look at the IsItDone function on line 50.<br />

ActionScript has numeric, or arithmetic, operators, but it also has other types of operators that<br />

perform different types of operations. For example, a comparison operator compares values to<br />

determine if one operand is greater than, less than, or equal to the other, and a logical operator<br />

calculates a true or false value, also called a Boolean value, for an expression.<br />

Now you’ll use an operator called the logical NOT operator to write an expression that shows and<br />

hides the puzzle pattern. The logical NOT operator, which is represented by an exclamation mark<br />

(!), calculates the opposite Boolean value of its operand. For example, the expression !true yields<br />

the value false.<br />

Introduction to ActionScript Tutorial 67


1 If necessary, choose File > Open and choose the version of the mypuzzle.fla file that you last saved.<br />

Note: You can also browse to your <strong>Flash</strong> <strong>MX</strong> application folder and open <strong>Tutorials</strong>/ActionScript/Finished/<br />

puzzle4.fla. If you do use the puzzle4.fla file, save the file with a new name in your My_Puzzle folder to maintain<br />

an unadulterated version of the original file.<br />

2 Click the Show/Hide Pattern edges button on the Stage. If the Actions panel isn’t open, choose<br />

Window > Actions.<br />

The Actions panel shows actions associated with the button.<br />

3 Select the following line of code in the Script pane:<br />

// ENTER code here<br />

4 In the Actions toolbox, choose Actions > Miscellaneous Actions and drag the evaluate action<br />

to the Script pane.<br />

When you add the action, it is enclosed in code called an event handler. The code looks like this:<br />

on (release) {<br />

;<br />

}<br />

5 In the Actions toolbox, double-click the evaluate action to add another empty line of code.<br />

The code now looks like this:<br />

on (release) {<br />

;<br />

;<br />

}<br />

6 Select the first empty line—the line with the first semicolon—and place the insertion point in<br />

the Expression text box.<br />

You’ll now enter code that hides the pattern movie clip; a user should see either the pattern<br />

movie clip or the edges movie clip, but not both.<br />

7 Enter _root.pattern._visible = false in the Expression text box.<br />

You can type the path directly in the Expression text box or use the Insert Target Path dialog<br />

box to select the pattern movie clip. If you use the Insert Target Path dialog box, select Dots<br />

and Absolute.<br />

Note: As you enter parameters and properties in normal mode, you might notice code hints—tooltips that appear<br />

suggesting the complete syntax for an action; you can click a code hint to enter the syntax. For more information<br />

about code hints, include enabling and disabling them, see “Using code hints” under Help > Using <strong>Flash</strong>.<br />

68<br />

Chapter 2


8 Select the second empty line and place the insertion point in the Expression text box.<br />

9 Type _root.edges._visible = ! in the Expression text box.<br />

Ignore the syntax error message that appears.<br />

The exclamation mark (!) is a logical NOT operator. In addition to simply typing it in the<br />

Expressions text box, you can add it to the text box from the Actions toolbox by choosing<br />

Operators > Logical Operators and double-clicking the exclamation mark.<br />

10 Enter _root.edges._visible again in the Expression text box after the operator.<br />

Your code should look like this:<br />

on (release){<br />

_root.pattern._visible = false;<br />

_root.edges._visible = !_root.edges._visible;<br />

}<br />

The first line of code inside the event handler sets the visibility of the pattern movie clip to<br />

false. The second line of code sets the visibility of the edges movie clip to the opposite of<br />

what it currently is. This creates a toggle that either shows or hides the movie clip.<br />

11 Choose File > Save As and enter a new filename. Use a consecutive naming scheme so you can<br />

revert to earlier versions of the file, if necessary.<br />

Introduction to ActionScript Tutorial 69


Control the flow of the movie<br />

Without ActionScript, a movie plays from Frame 1 to the last frame and either repeats from<br />

Frame 1 or stops. You can use ActionScript to control the progression of a movie more precisely;<br />

you can also use it to give the user control. For example, you could place an action in Frame 5<br />

that stops the movie until a user presses a Play button. This is a simple example of controlling the<br />

flow of a movie.<br />

You can use the if, else, and else if actions (also called statements) to create a more complex<br />

movie flow called logic. These three actions perform the following tasks:<br />

• The if action lets <strong>Flash</strong> check a condition in the movie and run certain actions if that<br />

condition is true.<br />

• The else statement tells <strong>Flash</strong> to run a different set of actions if the if condition is false.<br />

• The else if statement lets <strong>Flash</strong> check for another condition before running yet a different<br />

set of actions.<br />

Write a conditional statement<br />

You’ve already used an operator to show and hide a movie clip. Now you’ll use an if statement to<br />

create logic that shows and hides the piece numbers movie clip. For the sake of learning, this<br />

example uses a different ActionScript element to achieve the same result.<br />

1 If necessary, choose File > Open and choose the version of the mypuzzle.fla file that you last saved.<br />

Note: You can also browse to your <strong>Flash</strong> <strong>MX</strong> application folder and open <strong>Tutorials</strong>/ActionScript/Finished/<br />

puzzle5.fla. If you do use the puzzle5.fla file, save the file with a new name in your My_Puzzle folder to maintain<br />

an unadulterated version of the original file.<br />

2 On the Stage, click the Show/Hide Piece number matrix button. If the Actions panel<br />

isn’t open, choose Window > Actions. In the Actions toolbox, choose the Actions ><br />

Conditions/Loops category.<br />

3 Double-click the if action. The following code appears in the Actions panel:<br />

on (release) {<br />

if () {<br />

}<br />

}<br />

4 With the line of code that contains the if action selected, double-click the else action in the<br />

Actions toolbox.<br />

The code looks like the following:<br />

on (release) {<br />

if () {<br />

} else {<br />

}<br />

}<br />

5 Select line 3, which begins with if, and with the insertion point in the Condition text box,<br />

click the Insert Target Path button. Select the piecenumbers movie clip, Dots, and Absolute,<br />

and click OK. The following code appears in the Condition text box:<br />

_root.piecenumbers<br />

6 With the insertion point in the Condition text box, enter ._visible after<br />

_root.piecenumbers.<br />

70<br />

Chapter 2


7 From the Actions > Miscellaneous Actions category in the Actions toolbox, double-click the<br />

evaluate action to add an empty line of code.<br />

8 Enter _root.piecenumbers._visible = false in the Expression text box.<br />

You can use the Insert Target Path button or type the code manually. The code now looks like<br />

the following:<br />

on (release) {<br />

if (_root.piecenumbers._visible) {<br />

_root.piecenumbers._visible = false;<br />

} else {<br />

}<br />

}<br />

When the movie plays, <strong>Flash</strong> evaluates the expression inside the condition parentheses. The<br />

expression must equal one of the Boolean values: true or false. This example uses the<br />

condition of the if action to check if the piecenumbers movie clip is visible on the Stage. If<br />

the _visible property is true, ActionScript runs the code inside the curly brackets and sets<br />

the _visible property to false, which hides the movie clip on the Stage.<br />

9 In the Script pane, select the line of code with the else action and double-click the<br />

evaluate action.<br />

10 Enter _root.piecenumbers._visible = true in the Expression text box.<br />

The final ActionScript code looks like this:<br />

on (release) {<br />

if (_root.piecenumbers._visible) {<br />

_root.piecenumbers._visible = false;<br />

} else {<br />

_root.piecenumbers._visible = true;<br />

}<br />

}<br />

11 Choose File > Save As and enter a new filename. Use a consecutive naming scheme so you can<br />

revert to earlier versions of the file if necessary.<br />

Create commands and reuse code<br />

ActionScript has actions that let you control a movie in specific ways. For example, the play<br />

action moves the playhead forward in the Timeline, and the loadMovie action loads another<br />

<strong>Flash</strong> movie into the <strong>Flash</strong> Player. Each of these actions instructs <strong>Flash</strong> to perform a certain task.<br />

You may want to create your own commands in your movies. For example, in puzzle.fla, you need<br />

a command to scramble the puzzle pieces. To figure out how to write such a command with<br />

ActionScript, you must determine each step required to scramble the puzzle pieces and determine<br />

which ActionScript elements can be used to achieve those goals.<br />

First, the pieces must be spread out within a certain area on the Stage; each movie clip has an _x<br />

and _y property that you can use to set its position and a _rotation property that you can use to<br />

set its rotation. To place and rotate each piece randomly, you need to generate a random number<br />

to use in an expression. ActionScript has a built-in Math object with a random method that you<br />

can use for this purpose.<br />

Introduction to ActionScript Tutorial 71


A command in ActionScript is called a function. A function is a script that you can use over and<br />

over again in a movie to perform a certain task. For example, in puzzle.fla, every time a user clicks<br />

a Scramble Pieces button, the function Scramble is run, or called. This function places the puzzle<br />

pieces in random positions on the Stage. Instead of rewriting that same script on each of the two<br />

Scramble Pieces buttons, the function is written, or declared, once and called from each button.<br />

To examine the Scramble function, select Frame 1 in the main Timeline and open the Actions<br />

panel. Scroll down the Script pane until you see the Scramble function.<br />

You can think of a function as a machine that does extra work for you. The machine can produce<br />

different results depending on what you put into it. For example, if you put bananas in a blender,<br />

you get mashed bananas, not mashed peaches. The elements you pass to a function to work on are<br />

called parameters or arguments. Parameters are passed inside the parentheses that follow the<br />

function. For example, the function RotateDisplayOrDrag(whichPiece) is passed the name of<br />

a puzzle piece, and it operates only on that piece. Parameters allow you to reuse functions in many<br />

different situations.<br />

Functions are usually declared in the first frame of a movie. In the puzzle.fla files, the functions<br />

are declared in Frame 1.<br />

Write a function<br />

Now you’ll declare a function that will rotate, display, or drag each puzzle piece when the user<br />

clicks it.<br />

1 If necessary, choose File > Open and choose the version of the mypuzzle.fla file that you last saved.<br />

Note: You can also browse to your <strong>Flash</strong> <strong>MX</strong> application folder and open <strong>Tutorials</strong>/ActionScript/Finished/<br />

puzzle6.fla. If you do use the puzzle6.fla file, save the file with a new name in your My_Puzzle folder to maintain<br />

an unadulterated version of the original file.<br />

2 Select the first frame of the Actions layer and open the Actions panel if it’s not already open.<br />

3 Scroll down the Script pane and select line 31. The following commented line should<br />

be highlighted:<br />

// ENTER RotateDisplayOrDrag() function here<br />

4 From the Actions > User Defined Functions category in the Actions toolbox, double-click the<br />

function action.<br />

Type RotateDisplayOrDrag in the Name text box. Type whichPiece in the Parameters text<br />

box. The code for line 32 now looks like this:<br />

function RotateDisplayOrDrag (whichPiece) {<br />

}<br />

The whichPiece parameter, which identifies the selected puzzle piece, will be called three<br />

times in the body of the function. When the function is called, the passed parameter is<br />

substituted for whichPiece in each statement.<br />

72<br />

Chapter 2


5 From the Actions > Conditions/Loop category in the Actions toolbox, double-click the if<br />

action, the else if action, and the else action.<br />

Note: You can also select the actions from the Plus (+) pop-up menu<br />

The code looks like this:<br />

function RotateDisplayOrDrag (whichPiece) {<br />

if () {<br />

} else if () {<br />

} else {<br />

}<br />

}<br />

This code creates the logical structure of the function. You will fill in the conditions to be<br />

checked in each if statement. You will also fill in the code within each set of curly brackets<br />

that is executed when the conditions are true.<br />

6 Select the if statement line of code. Enter Key.isDown(18) in the Condition text box.<br />

Key is a built-in ActionScript object, which you can also find in the Objects > Movie ><br />

Key > Methods category. Key lets you determine what key a user pressed on the keyboard.<br />

The number 18 is the numerical representation of the Alt (Windows) and Option (Macintosh)<br />

keys. This line of code checks whether a user pressed those keys.<br />

To learn more about built-in objects, see “Use a built-in object” on page 76.<br />

7 From the Actions > Miscellaneous Actions category in the Actions toolbox, double-click the<br />

evaluate action to enter a new line of code. Type _root[whichPiece]._rotation += 90 in the<br />

Expression text box, with no space between the + and =.<br />

This line of code rotates the selected piece 90° if the user presses the Alt (Windows) or Option<br />

(Macintosh) key. The brackets let you dynamically retrieve the value of an instance name. For<br />

more information, see “Dot and array access operators” under Help > Using <strong>Flash</strong>.<br />

8 Select the else if line of code. Type Key.isDown(Key.SHIFT) in the Condition text box.<br />

This line of code checks whether a user pressed the Shift key.<br />

9 In the Actions > Miscellaneous Actions category in the Actions toolbox, double-click the<br />

evaluate action to enter a new line of code. Type pieceNumber = whichPiece.slice(5) in the<br />

Expression text box.<br />

This line of code displays the piece number in the text box on the Stage when a user presses the<br />

Shift key. The slice method of the String object removes a specified number of characters (in<br />

this case, 5) from the piece number’s instance, so that just the number of the piece appears. In<br />

effect, the method “slices” off the first five characters, then assigns the resulting number to the<br />

pieceNumber variable, which is in turn assigned to the text field on the Stage.<br />

10 Select the else line of code. In the Actions > Movie Clip Control category in the Actions<br />

toolbox, double-click the startDrag action.<br />

11 Type _root[whichPiece] in the Target text box and click Expression.<br />

Introduction to ActionScript Tutorial 73


12 Select Constrain to rectangle. Type 20 in the L (left) and T (top) text boxes. In the R (right)<br />

and B (bottom) text boxes, type 780 and 580, respectively.<br />

The word false in the script indicates that lockCenter (which indicates that the puzzle piece<br />

will always snap to the center of the mouse pointer when clicked) is not specified. The<br />

numbers 20, 20, 780, and 580 specify the left, top, right, and bottom coordinates of the text<br />

box on the Stage.<br />

When a user clicks a piece, the following function that you wrote is called. The function uses the<br />

Key object to determine if the Shift, Alt, or Option key is pressed when a piece is clicked. If the<br />

Shift key is pressed while a piece is clicked, a dynamic text box displays the puzzle piece number;<br />

if the key pressed is Alt (Windows) or Option (Mac), the puzzle piece rotates 90°. If Shift, Alt, or<br />

Option keys are not pressed, the user can drag the piece. Your code should look like this:<br />

function RotateDisplayOrDrag (whichPiece) {<br />

if (Key.isDown(18)) {<br />

_root[whichPiece]._rotation += 90;<br />

} else if (Key.isDown(Key.SHIFT)) {<br />

pieceNumber = whichPiece.slice(5);<br />

} else {<br />

startDrag(_root[whichPiece],false, 20, 20, 780, 580);<br />

}<br />

}<br />

Note: As you complete the tutorial, remember to save your work frequently.<br />

Call a function<br />

Functions can be called from any frame in a movie where you need a task completed. You must<br />

use a target path to call a function, just as you must use a path to access a variable or a movie clip.<br />

All functions in the puzzle.fla movie are declared in the first frame of the Actions layer, in the<br />

main Timeline, so the absolute path to each begins with _root.<br />

Now you’ll call the function that scrambles the puzzle pieces on the Stage.<br />

1 In the Timeline, hide the Scramble dialog and Start dialog layers, if they’re not already hidden.<br />

Select the Congrats dialog layer.<br />

74<br />

Chapter 2


2 On the Stage, double-click the Dialog—Congratulations symbol.<br />

Dialog—Congratulations<br />

symbol<br />

3 On the Stage, select the OK button. If the Actions panel isn’t open, choose Window > Actions.<br />

4 In the Actions > User-Defined Functions category of the Actions toolbox, double-click the<br />

call function action.<br />

5 With the insertion point in the Object text box of the Actions panel, click the Insert Target<br />

Path button. Verify Dots and Absolute are selected. Select _root and click OK.<br />

6 Type Scramble in the Method text box.<br />

The Scramble function doesn’t require any parameters; you can leave the Parameters text<br />

box empty.<br />

The code now looks like this:<br />

on (release) {<br />

_root.Scramble();<br />

}<br />

This is the ActionScript that calls the function. You’ll also need to add a few additional lines of<br />

code that belong inside the on(release) handler. You’ll do that in the next steps.<br />

With the _root.Scramble... line of code selected in the Script pane, double-click evaluate<br />

from the Actions > Miscellaneous Actions category in the Actions toolbox. Type<br />

_root.scramblebutton._visible = true in the Expression text box.<br />

Introduction to ActionScript Tutorial 75


7 Double-click the evaluate action again, to add another blank line. Type _root.dialog = false<br />

in the Expression text box.<br />

8 From the Actions > Miscellaneous Actions category of the Actions toolbox, double-click the<br />

evaluate action.<br />

9 From the Properties category in the Actions toolbox, double-click _visible. With the<br />

insertion point after _visible, type = 0 in the Expression text box.<br />

This code specifies that the dialog box is not visible after the user clicks the OK button.<br />

The final code appears as follows:<br />

on (release) {<br />

_root.Scramble();<br />

_root.scramblebutton._visible = true;<br />

_root.dialog = false;<br />

_visible = 0<br />

}<br />

10 Do one of the following to return to the main Timeline:<br />

• Choose Edit > Edit Document.<br />

• Click the Back button.<br />

• Click Scene 1.<br />

11 Choose File > Save As and enter a new filename. Use a consecutive naming scheme so you can<br />

revert to earlier versions of the file, if necessary.<br />

Note: As you complete the tutorial, remember to save your work frequently.<br />

Use a built-in object<br />

ActionScript has variables that let you store information; it has functions that let you create special<br />

commands and reuse code; it has actions that let you control the flow of a movie; and it has movie<br />

clips with properties that you can change.<br />

ActionScript also has another type of element called a built-in object. Objects provide a way of<br />

grouping information so that you can use it in a script. Objects can have properties, methods<br />

(which are like functions), and constants (for example, the numeric value of Pi).<br />

In the RotateDisplayOrDrag function that you created in “Create commands and reuse code”<br />

on page 71, you used the Key object to determine the last key a user pressed on the keyboard. The<br />

Key object is built into ActionScript to allow you to access information about the keyboard.<br />

Another ActionScript object is the MovieClip object. The MovieClip object is a collection of<br />

methods that you can use to manipulate movie clips, which are the most fundamental and<br />

powerful elements of <strong>Flash</strong>. To learn more about the special characteristics of the MovieClip<br />

object and using movie clips, see “Working with Movie Clips and Buttons” under Help > Using<br />

<strong>Flash</strong>.<br />

76<br />

Chapter 2


You will now use the onPress method of the MovieClip object to check whether the mouse<br />

pointer is touching a puzzle piece.<br />

1 If necessary, choose File > Open and choose the version of the mypuzzle.fla file that you last saved.<br />

Note: You can also browse to your <strong>Flash</strong> <strong>MX</strong> application folder and open <strong>Tutorials</strong>/ActionScript/Finished/<br />

puzzle7.fla. If you do use the puzzle7.fla file, save the file with a new name in your My_Puzzle folder to maintain an<br />

unadulterated version of the original file.<br />

2 Piece actions is a movie clip nested within each instance of a puzzle piece. To select the Piece<br />

actions movie clip from the Library panel hierarchy, click the Edit Symbols button in the lower<br />

right corner of the Timeline and choose Misc > Piece actions.<br />

The Piece actions movie clip opens in symbol-editing mode.<br />

3 In the Piece actions Timeline, select Frame 1 of the Actions layer.<br />

4 If the Actions panel is not already open, choose Window > Actions. In the Script pane, select<br />

line 3 with the following line of code:<br />

// ENTER code here<br />

Introduction to ActionScript Tutorial 77


5 In the Objects > Movie > MovieClip > Events category of the Actions toolbox, double-click the<br />

onPress action.<br />

The onPress method is a special type of action called an event handler, or simply an event. An<br />

event allows you to write a function that runs when a certain event occurs. Types of events<br />

include when the mouse button is pressed, when the playhead enters a frame, and when a<br />

movie clip loads.<br />

In this procedure, the code within the curly brackets that follow onPress runs when a user<br />

presses the mouse button in the movie.<br />

6 Type _parent in the Object text box.<br />

Because Piece actions is nested within the movie clip, _parent specifies that onPress should<br />

execute on code one level up, at the same level as the puzzle piece.<br />

7 In the Actions > Conditions/Loops category of the Actions toolbox, double-click the if action.<br />

8 Type !_root.dialog in the Condition text box. The code appears as follows:<br />

_parent.onPress = function(){<br />

if (!_root.dialog) {<br />

{<br />

};<br />

The code that you added in this step tests whether the value of the variable named dialog is<br />

true (visible) or false (not visible). If the value is true, then the next script to rotate and drag<br />

the puzzle piece will not run. If the value of the variable is false, then the following script will<br />

run. Users can’t rotate or drag a piece, or display its piece number, if the dialog box is showing.<br />

9 In the Actions toolbox, double-click the evaluate action in the Actions > Miscellaneous<br />

Actions category to add it inside the curly brackets of the if statement.<br />

10 Type _root.RotateDisplayOrDrag(_parent._name) in the Expression box.<br />

_name is the property for the name of the puzzle piece instance that the user clicks.<br />

The final code looks like this:<br />

_parent.onPress = function(){<br />

if (!_root.dialog) {<br />

_root.RotateDisplayOrDrag(_parent._name);<br />

}<br />

};<br />

11 Do one of the following to return to the main Timeline:<br />

• Choose Edit > Edit Document.<br />

• Click the Back button.<br />

• Click Scene 1.<br />

12 Choose File > Save As and enter a new filename. Use a consecutive naming scheme so you can<br />

revert to earlier versions of the file, if necessary.<br />

78<br />

Chapter 2


Test the movie<br />

“Test early and test often” is a mantra for Web developers. The sooner you test your movie, the<br />

easier it is to determine the cause of unexpected results. It’s a good idea to save multiple versions<br />

of your file using sequential names—for example, mypuzzle1.fla, mypuzzle2.fla, and so on, as<br />

you’ve been doing in this tutorial. This way, the highest numbered file is always the newest and it’s<br />

easy to revert to an earlier version.<br />

As you learned in the Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial, the <strong>Flash</strong> authoring tool includes a<br />

version of the <strong>Flash</strong> Player that lets you test your movie at any point during authoring by<br />

choosing Control > Test Movie. This version of the <strong>Flash</strong> Player has several commands and tools<br />

to help you troubleshoot your movie.<br />

The most common reason for unexpected results in a <strong>Flash</strong> movie is an incorrect path to a<br />

variable, function, object, or movie clip. This can cause a variable to contain the wrong value,<br />

prevent a function from being called, or prevent a movie clip from playing correctly.<br />

The trace action allows you to write notes and expressions in your scripts whose results are sent<br />

to a window called the Output window.<br />

Now you’ll add a trace action to test if a function was called successfully.<br />

Note: <strong>Flash</strong> also includes a Debugger, which lets you examine the values of global and local variables, including<br />

when they change as the movie plays. Additionally, with the Debugger you can use breakpoints to stop the movie<br />

and test ActionScript line by line. For more information, see “Using the Debugger” under Help > Using <strong>Flash</strong>.<br />

1 Choose File > Open and choose the version of the mypuzzle.fla file that you last saved.<br />

Note: You can also browse to your <strong>Flash</strong> <strong>MX</strong> application folder and open <strong>Tutorials</strong>/ActionScript/Finished/<br />

puzzle8.fla. If you do use the puzzle8.fla file, save the file with a new name in your My_Puzzle folder to maintain<br />

an unadulterated version of the original file.<br />

When the user clicks the OK button in the SWF movie, the puzzle pieces should scramble.<br />

You can use a trace action to test if the Scramble function is being called.<br />

2 In the Actions layer in the Timeline, select Frame 1 and open the Actions panel.<br />

3 In the Script pane, scroll to and select line 18, the commented line that says // enter trace<br />

action here.<br />

4 In the Actions toolbox, double-click the trace action from the Actions > Miscellaneous<br />

Actions category.<br />

5 Type Scramble function has been called in the Message text box.<br />

You are placing this message within the Scramble function.<br />

6 Save your document, then choose Control > Test Movie.<br />

Introduction to ActionScript Tutorial 79


7 Click the OK button in the SWF movie.<br />

The Output window appears, which traces events in your movie. Enlarge the window, as<br />

necessary, to read the messages.<br />

The message Scramble function has been called appears in the Output window.<br />

If the message did not appear, your next step would be to determine the reason why. The most<br />

likely reason is that you specified an incorrect path to the function.<br />

8 Close the Output window and SWF file and return to authoring mode.<br />

9 Choose File > Save As and enter a new filename. Use a consecutive naming scheme so you can<br />

revert to earlier versions of the file, if necessary.<br />

You’ve made great progress in learning ActionScript!<br />

80<br />

Chapter 2


The next steps<br />

By completing the tutorial, you’ve accomplished a great deal in a relatively short amount of time.<br />

You’ve learned how to use ActionScript to set up a <strong>Flash</strong> movie’s starting point, how to create<br />

commands and reuse code to make actions recur, and how to precisely control the flow of the<br />

movie. Using ActionScript variables and expressions, you know how to keep track of user activity<br />

in your movie and how to display changing content to your users. Finally, you’ve learned how to<br />

test your movie.<br />

To continue learning about ActionScript, see the online ActionScript Dictionary in the Help<br />

menu and articles in the <strong>Flash</strong> Support Center at www.macromedia.com/support/flash. From the<br />

Samples folder within your <strong>Flash</strong> <strong>MX</strong> application folder, you can also open an advanced version<br />

of the puzzle.fla movie and deconstruct the ActionScript that was used to create a timer and<br />

animated puzzle piece.<br />

Introduction to ActionScript Tutorial 81


82<br />

Chapter 2


CHAPTER 3<br />

Introduction to Components Tutorial<br />

You can use Macromedia <strong>Flash</strong> UI components to quickly and easily add simple user interface<br />

elements to your <strong>Flash</strong> document.<br />

This tutorial is designed to introduce components to beginner and intermediate <strong>Flash</strong> users and<br />

show how they can be used to easily create a simple application. Before taking this tutorial, you<br />

should complete the Introduction to <strong>Flash</strong> <strong>MX</strong> Tutorial and the Introduction to ActionScript<br />

Tutorial, which you can access by choosing Help > <strong>Tutorials</strong>.<br />

After completing this tutorial, you will know how to do the following tasks:<br />

• Add components to a <strong>Flash</strong> document<br />

• Configure the components<br />

• Add ActionScript to make the components work<br />

Types of components<br />

<strong>Flash</strong> <strong>MX</strong> provides the following components:<br />

Name<br />

Radio button<br />

Check box<br />

Push button<br />

Combo box<br />

List box<br />

Scroll pane<br />

Text scroll bar<br />

Action<br />

Represents a single choice in a group of mutually exclusive choices<br />

Represents a single choice<br />

Carries out a command when the user clicks it or presses Enter or Return<br />

Displays a list of choices<br />

Displays a list of choices<br />

Provides a scrollable window pane for viewing movie clips<br />

Adds a scroll bar to a text field<br />

83


How you can use components<br />

Here are some ways you can use components:<br />

Web form Design a form that asks for a user’s address, telephone, e-mail address, and other<br />

personal information, then validates the data before submitting it to a server.<br />

Build your car Create a Web form that allows users to order a car by selecting various graphic<br />

options instead of typing in the information. The fields are generated from the graphical<br />

interactions.<br />

Survey Build a multiple-question, multiple-part survey that instantly tallies the results and<br />

charts the resulting survey data.<br />

Photo album Create a personal photo album that takes a directory of images and thumbnails<br />

and wraps them with the <strong>Flash</strong> interface and navigation elements.<br />

Loan calculator Design an online amortization calculator that calculates loan payments.<br />

Web-based presentation template Create a template for slide-based presentations with simple,<br />

prebuilt navigation elements and a layout for images and text.<br />

View the completed form<br />

You can navigate through components in a form by doing the following:<br />

• Click the component to select it.<br />

• Press Tab to move forward; press Shift+Tab to move backward.<br />

• Use the arrow keys to navigate through menu items.<br />

1 Choose File > Open and navigate to the <strong>Flash</strong> <strong>MX</strong> program directory. Open <strong>Tutorials</strong>/<br />

Components/Finished/sweepstakes.swf. This is the completed movie.<br />

2 Use the navigation techniques described above to test each of the buttons and boxes on the form.<br />

3 Now open sweepstakes.fla. Choose File > Open and navigate to the <strong>Flash</strong> <strong>MX</strong> program<br />

directory. Open <strong>Tutorials</strong>/Components/Finished/sweepstakes.fla. This is the <strong>Flash</strong> document<br />

that generated the movie. Two keyframes are included in the Timeline.<br />

4 Examine the frame labeled pg 1. It contains the check box, combo box, and push buttons that are<br />

used to gather information. It also has two input text fields for the user’s name and e-mail address.<br />

5 Examine the frame labeled pg 2. It is the Results page and contains several dynamic text boxes<br />

to show the results of the information gathered on page 1. To save time, we have already<br />

created them for you.<br />

84<br />

Chapter 3


Create a form<br />

In this tutorial, you will use components to create a simple two-page form to enter a sweepstakes<br />

to win a free Stiletto electric car. The first page is used to gather the information, and the second<br />

page is used to display the results. You will follow these three steps to complete the form:<br />

• Add components to the form<br />

• Configure the components<br />

• Add ActionScript to the document to make the components work<br />

To get you started, we have included the background, text fields, and graphics for the form. You<br />

will add and configure components and ActionScript to make it an interactive form.<br />

Add components<br />

The first step is to add the components to the Stage and place them on the form. You will add a<br />

check box, a combo box, and a push button to the first page of the form. You will also add a push<br />

button to the second page.<br />

To add components to a document, you can either drag elements from the Components panel to<br />

the Stage, or double-click them in the Components panel to place them in the center of the Stage.<br />

After you add a component to a document, it appears in the document’s Library panel.<br />

It is a good idea to create a new layer for the components.<br />

1 Choose File > Open and navigate to the <strong>Flash</strong> <strong>MX</strong> program directory. Open <strong>Tutorials</strong>/<br />

Components/my_sweepstakes/mysweepstakes.fla.<br />

2 Choose File > Save As and save the file with a new name, such as newsweepstakes.<br />

3 Create a new layer and name it UI. You will place the components on this layer.<br />

4 Click Frame 6 in the UI layer of the Timeline. Choose Insert > Blank keyframe to add a blank<br />

keyframe. This will be used for components on the second page.<br />

5 Make sure the following panels are open:<br />

• Library panel (Window > Library)<br />

• Components panel (Window > Components)<br />

• Property inspector (Window > Properties)<br />

Add a check box<br />

Use the CheckBox component to create a box with a value of either true or false.<br />

1 Select Frame 1 in the UI layer.<br />

2 Drag the CheckBox component from the Components panel to the Stage. Place it under the<br />

paragraph that asks if the user wants to enter the sweepstakes.<br />

The component appears in the <strong>Flash</strong> UI Components folder in the Library panel.<br />

Introduction to Components Tutorial 85


Add a combo box<br />

Use the ComboBox component to create a simple drop-down menu of items that can be selected by<br />

users. You can also use a ComboBox to build a more complex drop-down menu that automatically<br />

scrolls to a menu item starting with the letter or letters entered into the text field by the user.<br />

• Drag the ComboBox component from the Components panel to the Stage. Place it under<br />

“Select your favorite color:”.<br />

The component appears in the <strong>Flash</strong> UI Components folder in the Library panel.<br />

Add push buttons<br />

Use the PushButton component to create two push buttons. One button will be on the first page<br />

and will be used to submit the information on the form. The next button will be on the second<br />

page and will be used to return to the first page and repopulate it with the values that were<br />

previously submitted.<br />

1 Drag the PushButton component from the Components panel to the Stage. Place it in the<br />

lower right corner of the form so it lines up horizontally with the name and e-mail text fields.<br />

The component appears in the <strong>Flash</strong> UI Components folder in the Library panel.<br />

After you have dragged a component from the Components panel to the Stage, you select<br />

additional instances of it from the Library panel.<br />

86<br />

Chapter 3


2 Go to the blank keyframe at Frame 6. In the Library panel, open the <strong>Flash</strong> UI Components<br />

folder and drag the PushButton component from the Library panel to the Stage. Place it in the<br />

lower right corner.<br />

Configure the components<br />

The next step is to configure the components so they are set up with the correct information for a<br />

user to select.<br />

You set the parameters for a component using the Parameters tab of the Property inspector or the<br />

Components Parameters panel.<br />

Advanced users can use API methods and properties for each component to set the parameters, size,<br />

appearance, and other properties of the component. The methods and properties available for each<br />

component element are listed in the ActionScript Dictionary under the name of the component.<br />

Configure the check box<br />

1 Select Frame 1 on the UI layer, then select the CheckBox component on the Stage. Its<br />

parameters are displayed in the Property inspector.<br />

2 Type sweepstakes_box in the Instance Name text box.<br />

3 Type Absolutely! in the Label text box.<br />

4 In the Initial Value Parameter pop-up menu, select True. This specifies whether the initial state<br />

of the CheckBox component is selected (True) or unselected (False).<br />

5 In the Label Placement parameter pop-up menu, leave the default value set to right alignment.<br />

The label will be displayed to the right of the check box.<br />

Introduction to Components Tutorial 87


6 Do not alter the Change Handler parameter.<br />

The Change Handler parameter is the function that you want to execute when the user selects<br />

an item. This function must be defined in the same Timeline as the component instance. This<br />

parameter is optional and needs to be specified only if you want an action to take place as soon<br />

as the user accesses a component.<br />

When you finish, the Property inspector should look like the following:<br />

7 In order to see the text you entered for the label on the Stage, you need to enable Live Preview,<br />

if it is not already enabled. Choose Control > Enable Live Preview. After live preview is<br />

enabled, you will see Absolutely next to the checkbox on the Stage.<br />

For more information about using the API methods of the FCheckBox component to set<br />

additional options for the component, see the FCheckBox (component) entry in the online<br />

ActionScript Dictionary in <strong>Flash</strong> Help.<br />

Configure the combo box<br />

1 Select the ComboBox component on the Stage. Its parameters are displayed in the Property<br />

inspector.<br />

2 Type color_box in the Instance Name text box.<br />

3 Make sure the Editable parameter is set to False. This prevents users from typing in their own text.<br />

88<br />

Chapter 3


4 The Labels parameter displays a list of values users can select. Click the Labels field, then click<br />

the magnifying glass to open the Values pop-up window. Click the Plus (+) button to enter a<br />

new value.<br />

5 Click in the default value field, then type Lightning for the first value.<br />

6 Click the Plus (+) button to enter the next value. Click in the default value field, then type<br />

Cobalt for the next value.<br />

7 In the same manner, add Emerald to the list.<br />

When you are finished, the Values pop-up window should look like the following:<br />

8 Click OK to close the Values pop-up window.<br />

The Data parameter is optional. It is used to specify the values associated with the items<br />

(labels) in the list box. There is no need to do that for this tutorial.<br />

Introduction to Components Tutorial 89


9 The Row Count parameter specifies how many rows are displayed in the window. Since there<br />

are three options, change the value to 3.<br />

There is no need to enter a Change Handler parameter name.<br />

When you are finished, the Property inspector should look like the following:<br />

For more information about using API methods to change additional properties, see the<br />

FComboBox (component) entry in the online ActionScript Dictionary in <strong>Flash</strong> Help.<br />

Configure the push buttons<br />

1 Select the PushButton component in Frame 1.<br />

The component’s parameters are displayed in the Property inspector.<br />

2 Type submit_btn in the Property inspector Instance Name text box.<br />

3 Type Submit in the Property inspector Label text box.<br />

This text is displayed in the body of the button.<br />

4 Type onClick for the Click Handler name. Later you will write ActionScript to define what the<br />

Click Handler should do.<br />

When you are finished, the Property inspector should look like the following:<br />

90<br />

Chapter 3


5 Select the PushButton component in Frame 6.<br />

6 Type return_btn in the Property inspector Instance Name text box.<br />

7 Type Return in the Property inspector Label text box.<br />

8 Type onClick for the Click Handler name.<br />

For more information about using the API methods of the FPushButton component to change<br />

additional properties, see the FPushButton (component) entry in the online ActionScript<br />

Dictionary in <strong>Flash</strong> Help.<br />

Write ActionScript to gather the data<br />

Some of the ActionScript will be for the entire movie, while some will be related to a particular<br />

frame. The following table will help you keep track of instance names.<br />

Instance name<br />

Description<br />

color_box Color combo box on page 1<br />

sweepstakes_box Sweepstakes check box on page 1<br />

submit_btn Submit push button on page 1<br />

name Input text box for name on page 1<br />

email Input text box for e-mail address on page 1<br />

return_btn Return push button on page 2<br />

name_result<br />

email_result<br />

color_result<br />

sweepstakes_text<br />

Dynamic text box on page 2 to display the user’s name<br />

Dynamic text box on page 2 to display the user’s e-mail address.<br />

Dynamic text box on page 2 to display the user’s color selection<br />

Dynamic text box on page 2 that displays different text if the user has chosen or not<br />

chosen to enter the sweepstakes<br />

Write ActionScript for the entire movie<br />

ActionScript for components is placed in keyframes. The Click Handler parameter specifies what<br />

happens when the PushButton component is activated. The default value is onClick, which<br />

means that when the user clicks one of the push buttons, it is activated. We will begin by creating<br />

a function for onClick. This will be a branching function that will first determine whether the<br />

button pushed was the Submit or the Return button, then carry out actions accordingly.<br />

1 Create a new layer and name it All Actions. This will be used for ActionScript that should run<br />

throughout the movie.<br />

2 If the Actions panel is not open, choose Window > Actions.<br />

3 Switch to expert mode by pressing Control+Shift+E (Windows) or Command+Shift+E<br />

(Macintosh), or by clicking the control in the upper right corner (a triangle with a check mark<br />

above it) and selecting Expert Mode from the pop-up menu.<br />

Introduction to Components Tutorial 91


4 First, enter the callback function for the push buttons. This is a conditional statement that<br />

branches depending on which button is clicked. If the Submit button is clicked, it will branch to<br />

the getResults function and go to page 2. If the Return button is clicked, it will go to page 1.<br />

Enter the following code in the Actions panel.<br />

// push button callback<br />

function onClick(btn) {<br />

if (btn == submit_btn) {<br />

getResults();<br />

gotoAndStop("pg2");<br />

} else if (btn == return_btn) {<br />

gotoAndStop("pg1");<br />

}<br />

}<br />

Note: Although it is not recommended, if you don’t want to write the ActionScript, you can copy the text from this<br />

tutorial and paste it into the Actions panel.<br />

5 Now, write the getResults function. This gets the results from the sweepstakes check box and<br />

the color combo box. It gets the results from the combo box as a label so it can show the results.<br />

// get results from pg 1<br />

function getResults() {<br />

sweepstakes_result = sweepstakes_box.getValue();<br />

color_result = color_box.getSelectedItem().label;<br />

selectedItem = color_box.getSelectedIndex();<br />

}<br />

6 Next, write the initValues function. This initializes the values on page 1 with the values the<br />

user has previously selected. It is run when the user clicks the Return button.<br />

// initialize the values on pg 1 with the values the user has previously<br />

selected<br />

function initValues() {<br />

sweepstakes_box.setValue(sweepstakes_result);<br />

if (!started) {<br />

color_box.setSelectedIndex(0);<br />

started = true;<br />

} else {<br />

color_box.setSelectedIndex(selectedItem);<br />

}<br />

}<br />

92<br />

Chapter 3


7 Finally, add a call to the initValues function to the beginning of the ActionScript. When you<br />

finish, the ActionScript should look like this:<br />

initValues();<br />

// push button callback<br />

function onClick(btn) {<br />

if (btn == submit_btn) {<br />

getResults();<br />

gotoAndStop("pg2");<br />

} else if (btn == return_btn) {<br />

gotoAndStop("pg1");<br />

}<br />

}<br />

// initialize the values on pg 1 with the values the user has previously<br />

selected<br />

function initValues() {<br />

sweepstakes_box.setValue(sweepstakes_result);<br />

if (!started) {<br />

color_box.setSelectedIndex(0);<br />

started = true;<br />

} else {<br />

color_box.setSelectedIndex(selectedItem);<br />

}<br />

}<br />

// get results from pg 1<br />

function getResults() {<br />

sweepstakes_result = sweepstakes_box.getValue();<br />

color_result = color_box.getSelectedItem().label;<br />

selectedItem = color_box.getSelectedIndex();<br />

}<br />

You have completed the script that needs to run for the entire movie. However, you still need to<br />

add script for the frames in page 1 and page 2.<br />

Add ActionScript to each keyframe<br />

Some of the ActionScript needs to be executed only when a user selects a particular frame. In<br />

order to make the ActionScript work, you need to name each keyframe.<br />

1 Create a new layer and name it Frame Actions. Select Frame 1, then choose Insert > Blank<br />

Keyframe to insert a keyframe. Use the Property inspector to name the keyframe pg1. In the<br />

same manner, insert a keyframe at Frame 6 and name it pg2.<br />

2 Select the keyframe in Frame 1 of the Frame Actions layer and write the following ActionScript<br />

to stop the movie at Frame 1 (pg1):<br />

stop();<br />

Introduction to Components Tutorial 93


3 (Optional) If you want to display certain text if the user has selected the sweepstakes check box<br />

and other text if the user has not, you can write a conditional statement with text that will go<br />

into the sweepstakes_text dynamic text field on page 2. Select the keyframe named pg2 in the<br />

Frame Actions layer and enter the following in the Actions panel:<br />

// sweepstakes text<br />

if (sweepstakes_result==true) {<br />

sweepstakes_text = "You have been entered in the Stiletto Fantasy<br />

sweepstakes. Winners are announced at the end of each month.";<br />

} else {<br />

sweepstakes_text = "You have not been entered in the Stiletto Fantasy<br />

sweepstakes.";<br />

}<br />

Note: Do not cut and paste this ActionScript into the Actions panel. It will not work properly, because there are<br />

line breaks between the first and second lines of text.<br />

Test your movie<br />

To see what the components look like, run your movie in the <strong>Flash</strong> Player 6.<br />

1 Choose Control > Test Movie.<br />

The movie is run in the <strong>Flash</strong> Player.<br />

2 Select and deselect the check box to be sure it works.<br />

3 Select a color and make sure it appears on page 2.<br />

4 When you are finished, choose File > Close to close the movie in the player.<br />

5 If you noticed any errors, use the Arrow tool to select the component, then make the<br />

corrections in the Property inspector. If necessary, retest the movie.<br />

The next steps<br />

This tutorial has presented the basic steps for creating a simple group of components and then<br />

displaying the results. For more information, see Using <strong>Flash</strong> and the ActionScript Dictionary,<br />

both found in the Help menu.<br />

94<br />

Chapter 3


CHAPTER 4<br />

Introduction to Learning Interactions Tutorial<br />

Macromedia <strong>Flash</strong> <strong>MX</strong> quiz templates offer a streamlined process for developing e-learning<br />

systems that can send tracking data to a web sever-side learning management system (LMS). The<br />

templates are compliant with Aviation Industry Computer-Based Training Committee (AICC)<br />

protocol and Shareable Content Object Reference Model (SCORM) standards.<br />

For AICC or SCORM tracking, your Windows users must have Internet Explorer 4.0 or<br />

Netscape Navigator 4.0 or later. Macintosh users must have Netscape 4.5 or later. Tracking to an<br />

LMS will not work with Internet Explorer on the Macintosh.<br />

The quiz template that you’ll use in this tutorial includes six different types of interactions<br />

(including Multiple Choice, Drag and Drop, and Hot Spot). The last frame in the template uses<br />

cumulative data to display quiz results. Additionally, the quiz templates in <strong>Flash</strong> <strong>MX</strong> already<br />

include the necessary ActionScript and navigation controls, allowing you to focus less on<br />

development and more on tailoring the quiz content to meet your learning objectives.<br />

What you should know<br />

Although this tutorial is designed for beginning <strong>Flash</strong> users, you should be familiar with the<br />

basic <strong>Flash</strong> concepts presented in the learning media that ship with <strong>Flash</strong> <strong>MX</strong>. To access the<br />

lessons, open <strong>Flash</strong> and choose Help > Lessons. The introductory tutorial is available by choosing<br />

Help > <strong>Tutorials</strong> > Introduction to <strong>Flash</strong> <strong>MX</strong>. Additionally, because the quiz templates rely on the<br />

use of <strong>Flash</strong> user interface (UI) components, you’ll find it helpful to read about components<br />

(Help > Using Components).<br />

95


What you’ll learn<br />

This tutorial demonstrates how to modify <strong>Flash</strong> quiz templates to create a movie that uses six<br />

different types of learning interactions. The tutorial takes approximately 1 1/2 hours to complete,<br />

depending on your experience, and will teach you how to accomplish the following tasks in<br />

designing a quiz:<br />

• Analyze the quiz template and learning interactions<br />

• Specify LMS tracking<br />

• Add custom graphics and components<br />

• Modify True and False, Fill in the Blank, Multiple Choice, Drag and Drop, Hot Object, and<br />

Hot Spot interactions<br />

• Add an interaction to the Timeline<br />

• Publish the movie to conform to AICC tracking<br />

Open a new document from a quiz template<br />

<strong>Flash</strong> <strong>MX</strong> includes three templates that each have a distinct graphical format, although the quiz<br />

functionality is identical.<br />

1 Open <strong>Flash</strong> <strong>MX</strong> and choose File > New from Template.<br />

2 In the New Document dialog box, select Quiz as the category.<br />

A preview of a quiz template appears in the dialog box.<br />

3 Under Category Items, select each of the three quizzes, one after the other, to preview<br />

the templates.<br />

4 Select Quiz_style1 and click Create.<br />

5 Choose File > Save As, and name the document MyQuiz.fla. Browse to your <strong>Flash</strong> <strong>MX</strong> folder<br />

and save the document in <strong>Tutorials</strong>/QuizTutorial, then click Save.<br />

Note: Throughout the tutorial, remember to test and save your work frequently.<br />

Take a tour of the quiz template<br />

The quiz FLA file includes the following layers:<br />

• A hidden Instructions layer that explains how to use the template. You can show the<br />

Instructions layer and click each of the eight frames in the document to view steps on using the<br />

template, then hide the layer. The Instructions layer is a guide, which is not included in your<br />

published movie.<br />

• A Title layer, which includes title text designed to appear on every frame in the document.<br />

• An Interactions layer, which includes components for six different types of interactions in<br />

Frames 2 through 7. These interactions include True or False, Fill in the Blank, Multiple<br />

Choice, Drag and Drop, Hot Object, and Hot Spot.<br />

• A _controls layer, which holds the Quiz component that you can modify.<br />

• A _bckgrnd layer containing objects included in all frames of the template.<br />

• An _actions layer that contains simple ActionScript to make the playhead stop at each frame.<br />

96<br />

Chapter 4


Analyze the Quiz component<br />

Frames 1 through 7 in the Quiz template contain the Quiz component, which lets you set<br />

parameters that determine how to present the quiz to users.<br />

1 Click Frame 1 of the Interactions layer.<br />

2 To view the entire Welcome page and Quiz component, select Show All from the Stage View<br />

pop-up menu.<br />

3 Click the Quiz component, to the left of the Stage. In the Property inspector, click Launch<br />

Component Parameters Panel.<br />

4 If the text in the Component Parameters panel is too small to be legible, drag a corner of the<br />

panel to enlarge it.<br />

5 Although you will not change any of the default settings on the Component Parameters panel,<br />

view the options that the panel lets you specify:<br />

• Randomize, if selected, specifies that questions appear to the user in random order, not<br />

necessarily in the order in which they appear across the Timeline.<br />

• Questions to Ask, if set to 0, presents the user with all questions included in the quiz. You can<br />

also set the number to be less than the number of questions in the quiz. If you specify a number<br />

less than the total number and select Randomize, each launch of the quiz presents a subset of<br />

the total number of questions, in random order. If you specify a number larger than the number<br />

of questions in the quiz, the quiz presents all of the questions without duplicating them.<br />

• Login File URL redirects users to the specified URL where they can log in if they have not<br />

logged in through an AICC-compliant LMS.<br />

Note: If the user does log in through an AICC-compliant LMS, but the HTML parameters that launch the movie<br />

do not exist, the login file URL redirects the user to the specified URL.<br />

Introduction to Learning Interactions Tutorial 97


• The Activity ID and Activity Name fields correspond to the activity ID and activity name in<br />

your LMS. If you’re not using an LMS, you can either accept the default entries or delete the<br />

default entries and leave the fields blank.<br />

• Show Results Page, if selected, displays the quiz results in Frame 8 of the quiz template to users<br />

upon completion of the quiz.<br />

6 When you finish viewing the Component Parameters panel, close it.<br />

Analyze a learning interaction<br />

Learning interactions immerse users in e-learning content by requiring active participation. The<br />

interactions included in <strong>Flash</strong> offer you the choice of using several types of interactions in a movie.<br />

1 In the Timeline, select Frame 3 of the Interactions layer.<br />

The Stage contains dynamic text fields, and one input text field, all grouped within the Fill in<br />

the Blank interaction movie clip. During runtime, the text that you specify in the Component<br />

Parameters panel for the interaction populates the dynamic text fields.<br />

2 If the Library panel is not open, choose Window > Library. Expand the panel, if necessary.<br />

Expand the 2_Learning Interactions folder to view the six interactions in the template.<br />

3 Click any of the six interactions, such as Drag and Drop, to see a preview of it. You can see that<br />

the interaction is really a set of objects, such as movie clips, graphics, and components,<br />

grouped together.<br />

To use a learning interaction, you break it apart, then modify the individual objects that<br />

comprised the group.<br />

4 When you finish viewing the interactions, close the Library panel.<br />

Note: You can add stand-alone learning interactions to any <strong>Flash</strong> document, even if you’re not using the quiz<br />

templates. To access these interactions outside of a quiz template, choose Window > Common Libraries > Learning<br />

Interactions. Stand-alone interactions, when used in <strong>Flash</strong> documents outside of a quiz template, are not designed<br />

for use with SCORM tracking.<br />

Test the quiz template<br />

The quiz templates are designed for you to test them immediately, to see how the<br />

interactions perform.<br />

1 Choose Control > Test Movie.<br />

2 View the text and navigation on the Welcome page, then click the Next button at the lower<br />

right of the movie.<br />

98<br />

Chapter 4


Answer a True or False interaction<br />

In the True or False question, as with all interactions in the quiz, the Check Answer button is not<br />

active until you select a response. The feedback text instructs you to click a radio button.<br />

1 Select either True or False, and watch the feedback text change. Click Check Answer.<br />

The feedback text indicates whether or not you answered the question correctly, and the Check<br />

Answer button is now inactive.<br />

2 Click the Next button.<br />

Answer a Fill in the Blank interaction<br />

The Fill in the Blank interaction lets you type a response in an input text field. When you click<br />

Check Answer, the quiz template checks the response against matching phrases specified in the<br />

template. You can configure the component parameters to accept phrases that are either a close<br />

match or an exact match.<br />

• Type your answer to the Fill in the Blank interaction, and click Check Answer. After viewing<br />

the response, click Next.<br />

Answer a Multiple Choice interaction<br />

The Multiple Choice interaction lets you answer a question by selecting one or more responses.<br />

1 Click one or more check boxes to answer the question, then click Check Answer.<br />

2 View the feedback and click Next.<br />

Introduction to Learning Interactions Tutorial 99


Drag and drop objects onto targets<br />

The Drag and Drop interaction lets you respond to a question by dragging objects, which are<br />

usually graphical, to corresponding targets. You add to these objects to the template when you set<br />

up the quiz. For example, the question might ask users to drag a painting to the artist who created<br />

it, or arrange a sequence of objects in a certain order.<br />

1 Drag the numbered Drag squares close to either a corresponding numbered or incorrect target,<br />

then release the mouse button to see the object snap to the target. When you’ve placed all four<br />

Drag objects, click Reset.<br />

Reset is a helpful feature for users who complete part of the interaction, then realize they want<br />

to respond differently.<br />

2 Drag the objects to targets again and click Check Answer.<br />

3 View the response and click Next.<br />

Select a hot object<br />

The Hot Object interaction lets you respond to a question by clicking one or more objects to select<br />

them. You can think of a Hot Object interaction as a graphical version of a multiple-choice question.<br />

The Hot Object interaction is designed for you to add graphics to the template. Object 4 is<br />

specified as the correct object in the component parameters.<br />

1 Click object 4, to see how the interaction offers visual feedback when an object is clicked.<br />

A red tint appears over the clicked object.<br />

2 Click Check Answer. View the response and click Next.<br />

Select a hot spot<br />

The Hot Spot interaction lets users respond by clicking a region on the Stage. For example, you’ll<br />

use the Hot Spot interaction in this tutorial to have users click the part of the camera that allows<br />

you to take a picture. You’ll add an image of a camera to the Stage, and configure the interaction<br />

so that users can click a variety of camera parts, with the shutter release specified as the correct<br />

part to click.<br />

1 Click one of the numbered areas on the Stage, then click Check Answer.<br />

2 View the response and click Next.<br />

100 Chapter 4


View the quiz results<br />

The quiz template is designed to automatically track results and send them to a learning<br />

management system configured for your quiz.<br />

When you finish viewing the quiz results, close the SWF movie.<br />

View a completed version of the learning interaction tutorial file<br />

Now you’ll view a completed version of the file you’ll create from the quiz template.<br />

1 In <strong>Flash</strong> <strong>MX</strong>, choose File > Open. In your <strong>Flash</strong> <strong>MX</strong> folder, browse to <strong>Tutorials</strong>/QuizTutorial/<br />

Assets and double-click learning.fla to open the quiz in the authoring environment.<br />

2 Choose Control > Test Movie. Take the quiz to see how the designer modified the template.<br />

When you finish taking the quiz, close the SWF window and learning.fla, and return to<br />

MyQuiz.fla.<br />

Introduction to Learning Interactions Tutorial 101


Modify the Welcome page<br />

You’ll delete the existing background, and replace it with a gradient background. You’ll then add<br />

and modify text, and use an external library to add assets to the document.<br />

1 In the Timeline, hide the Instructions layer if it’s not already hidden.<br />

2 Lock all layers except the _bckgrnd layer, and select Frame 1 of that layer.<br />

3 On the Stage, verify that the background is selected (a bounding box appears around the<br />

Stage), and press Backspace or Delete.<br />

Create a gradient background<br />

A gradient displays subtle variations of a color, or transitions between two or more colors. You’ll<br />

create a gradient that blends white and blue.<br />

Draw a rectangle<br />

You’ll now draw a simple rectangle as the first step in creating a gradient background.<br />

1 In the toolbox, select the Rectangle tool.<br />

2 In the toolbox, click the Stroke Color control. Select No Stroke (the button with the red<br />

diagonal line above the color palette).<br />

The selected fill color of the shape is unimportant; you’ll soon change the color.<br />

3 Starting from the upper left corner of the Stage, drag to the lower right corner of the Stage to<br />

draw a rectangle that covers the Stage.<br />

Note: While completing the tutorial, you may find it useful to undo a change you’ve made. <strong>Flash</strong> can undo several<br />

of your recent changes, depending on the number of undo levels you have set in Preferences. To undo, choose<br />

Edit > Undo or press Control+Z (Windows) or Command+Z (Macintosh). Conversely, you can redo what you’ve<br />

undone by choosing Edit > Redo or pressing Control+Y (Windows) or Command+Y (Macintosh).<br />

102 Chapter 4


Specify a color for the gradient<br />

White is the first color you’ll add to your gradient.<br />

1 In the toolbox, select the Pointer tool. On the Stage, click inside the rectangle to select the fill.<br />

2 If the Color Mixer is not open, choose Window > Color Mixer.<br />

3 To expand the Color Mixer, click the white arrow in the panel title bar. If the Color Mixer is<br />

not fully expanded, click the arrow in the lower right of the panel.<br />

4 In the Fill Style pop-up menu, select Radial.<br />

5 If the gradient slider to the left of the color bar is not selected, with a small triangle above it, click it.<br />

Gradient slider<br />

6 Click the color box in the upper left corner of the window to open the color palette. Use one of<br />

the following methods to select white:<br />

• Move the eyedropper over the color swatches until you find white with the hexadecimal value<br />

of FFFFFF, then click the swatch to select it.<br />

• Type FFFFFF in the hexadecimal value text box and press Enter or Return.<br />

Add a second gradient color<br />

You’ll now add blue to the gradient.<br />

1 In the Color Mixer, click the gradient slider to the right of the gradient bar to select it.<br />

2 Click the color box to open the color palette, and select the blue with a hexadecimal value<br />

of 003366.<br />

Remember, you can either type the hexadecimal value in the hexadecimal value text box and press<br />

Enter or Return, or you can find and select the color swatch with the same hexadecimal value.<br />

Introduction to Learning Interactions Tutorial 103


3 In the toolbox, select the Fill Transform tool. On the Stage, click anywhere inside the rectangle.<br />

An ellipse that indicates the shape and location of the gradient appears around the Stage (resize<br />

the Stage view, as necessary). The ellipse has controls for the location, width, scale, and<br />

rotation of the radial gradient.<br />

Center control<br />

Circular middle<br />

handle<br />

4 Drag the circular middle handle, which controls the size of the gradient, to the right to make<br />

the ellipse larger, spreading out the lighter area of the gradient.<br />

104 Chapter 4


5 Drag the gradient center control toward the lower right side of the Stage.<br />

6 Lock the _bckgrnd layer.<br />

Modify and align text<br />

You can modify text in the template to specify attributes.<br />

1 In the Timeline, unlock the Title layer. With the Pointer tool, select and delete the text field on<br />

the stage that contains the words Practice Quiz. Lock the Title layer.<br />

2 Unlock the Interactions layer and select Frame 1 of the layer.<br />

3 In the toolbox, select the Pointer tool. On the Stage, double-click the Welcome text. Drag to<br />

select the Welcome text and use the Property inspector to set the text as 16 point, Arial, bold.<br />

4 Select the Welcome text again and type Introduction to Photography.<br />

5 Select the Pointer tool and use the Property inspector to give the Introduction to Photography<br />

text x and y coordinates of 10.7 and 14.5, respectively.<br />

6 Select the Text tool and click the Stage underneath the first text field to create another text<br />

field. Use the Property inspector to set the field to Arial 12 point bold. Type The World of<br />

35mm Photography Quiz.<br />

7 Use the Pointer tool to select the new text field, and use the Property inspector to give the text<br />

x and y coordinates of 9.7 and 34.5, respectively.<br />

8 In the toolbox, select the Line tool and select Black as the stroke color. In the Property<br />

inspector, verify that 1 is selected for the stroke height, and Solid is selected for the stroke style.<br />

Introduction to Learning Interactions Tutorial 105


9 To constrain the line, hold Shift and draw a horizontal line from the lower right edge of the<br />

title text, after the word Photography, to end slightly before the edge of the Stage.<br />

10 With the Pointer tool, select the text that states “Click the next button to continue.” Use the<br />

Property inspector to give the text an x coordinate of 333.4 and a y coordinate of 339.9.<br />

Use assets from a shared library<br />

The assets that you’ll use in your document exist in a separate FLA file, which you will open as a<br />

library. Assets that you use from the external library become part of the MyQuiz.fla library. You’ll<br />

now replace the navigation button with a different navigation button, which has the same name,<br />

from the LearningAssets.fla library.<br />

1 In the Timeline, unlock the _controls layer and select Frame 1 of that layer.<br />

2 Choose File > Open as Library.<br />

3 In the Open as Library dialog box, browse to the <strong>Tutorials</strong>/QuizTutorial/Assets folder in your<br />

<strong>Flash</strong> <strong>MX</strong> folder. Select LearningAssets.fla, then click Open.<br />

The library items from the LearningAssets.fla file are now available for your use.<br />

4 In the LearningAssets.fla library, go to the 1_Quiz Files > 0_Assets subfolder and drag mc,<br />

frameNav to anywhere on the Stage or the workspace.<br />

A Resolve Library Conflict dialog box appears, because you dragged an instance of a symbol<br />

that already exists in your MyQuiz library.<br />

106 Chapter 4


5 In the Resolve Library Conflict dialog box, select Replace Existing Items (not undoable)<br />

and click OK.<br />

In addition to dragging a new instance of the button onto the Stage, you’ve replaced the<br />

original mc, frameNav button with the new version.<br />

Note: You can also drag symbols directly from one library to another.<br />

6 On the Stage, select the button that you just dragged to the Stage and press Backspace or Delete.<br />

You do not need the second instance on the Stage once the first instance, in the lower right<br />

corner of the Stage, is replaced.<br />

7 With the Pointer tool, select the mc, frameNav button and use the Property inspector to give it<br />

an x coordinate of 464.6 and a y coordinate of 369.4.<br />

8 Select Frame 1 on the Interactions layer. Drag Camera1.png from the Images folder in the<br />

LearningAssets.fla library to the Stage, placing the camera slightly off center, within the light<br />

area of the gradient background.<br />

Introduction to Learning Interactions Tutorial 107


Modify a True or False interaction<br />

Each interaction has a component that you modify in the Component Parameters panel.<br />

To modify the True or False component, you’ll add the question text and specify whether the<br />

statement is true or false.<br />

1 In the Timeline, select Frame 2 on the Interactions layer.<br />

2 On the Stage, verify that the True or False component, as well as the grouped Stage objects, are<br />

selected. (A bounding box surrounds the objects.)<br />

Bounding box<br />

True or False<br />

component<br />

3 Choose Modify > Break Apart.<br />

Bounding boxes appear around individual objects on the layer.<br />

Note: Throughout the tutorial, you will break apart the learning interactions to modify the template. Be careful<br />

to use the Break Apart command once only with each interaction. If you choose Break Apart a second time for<br />

an interaction, the interaction becomes unusable, and you must replace it with the stand-alone interaction from<br />

the library.<br />

4 Deselect all selected objects by pressing Control+Shift+A or clicking an empty space in<br />

the workspace.<br />

5 To the left of the Stage, select the True or False component. In the Property inspector, click<br />

Launch Component Parameters Panel.<br />

6 Select the text in the Question text box and type The higher the aperture setting, the more<br />

light passes through the lens.<br />

Note: The question text appears in the dynamic text field on the Stage during runtime; you do not type question<br />

text on the Stage.<br />

108<br />

Chapter 4


7 Select the False distractor (choice).<br />

Note: While the word “distractor” is often defined as an incorrect choice that distracts the user from the correct<br />

choice, in this tutorial we use the term to refer to any choice, correct or incorrect.<br />

8 Click Options, at the bottom of the panel, and change the Feedback text:<br />

• Initial Feedback is the text the user sees in the Template_Feedback dynamic text field before<br />

answering the interaction. For the Initial Feedback text box, select the existing text and type<br />

Click a radio button.<br />

• Correct Feedback is the text the user sees after answering the question correctly and clicking<br />

Check Answer. For Correct Feedback, select the existing text and type Correct!<br />

• Incorrect Feedback is the text the user sees after answering a question incorrectly and clicking<br />

Check Answer. Select the existing text in the Incorrect Feedback text box and type Sorry. Your<br />

answer is incorrect.<br />

9 Verify that Off is selected for Navigation, and close the Component Parameters panel.<br />

Because the template has its own built-in navigation, you do not specify navigation in the<br />

Component Parameters panel.<br />

The Knowledge Track options are for use with your LMS.<br />

Note: You will use the Component Parameters panel for each interaction. You can either close the panel after<br />

configuring the parameters, or move it out of the way until you’re ready to use it again.<br />

Modify text and add a graphic to the True or False interaction<br />

For the True and False interaction, you’ll move both the question text and the CheckBox<br />

components.<br />

1 In the Timeline, verify that Frame 2 on the Interactions layer is still selected. Use the Pointer<br />

tool to select the Your Question Will Appear Here text. Use the Property inspector to make the<br />

text Arial 14-point bold, with an x coordinate of 10.7 and a y coordinate of 14.5.<br />

2 With the Pointer tool, select the True component on the Stage. Give it an x coordinate of 11.7<br />

and a y coordinate of 49.5.<br />

3 Select the False component on the Stage and place it so that x = 11.7 and y = 70.8.<br />

Introduction to Learning Interactions Tutorial 109


4 Drag lens.png from the Images folder in the LearningAssets.fla library toward the center of the<br />

Stage, where the background gradient is lightest.<br />

Note: As you complete the tutorial, remember to save and test your work frequently. Testing is especially<br />

important when modifying learning interactions to ensure your quiz works as expected.<br />

Modify a Fill in the Blank interaction<br />

To modify the Fill in the Blank component part of the interaction, you specify the question text,<br />

then specify all answers that are acceptable as correct.<br />

1 In the Timeline, select Frame 3 on the Interactions layer.<br />

2 On the Stage, verify that the objects on the layer are selected. Choose Modify > Break Apart.<br />

3 Deselect all selected objects by pressing Control+Shift+A or clicking an empty space in<br />

the workspace.<br />

4 To the left of the Stage, select the Fill in the Blank component. If necessary, launch the<br />

Component Parameters panel from the Property inspector.<br />

5 Select the text in the Question text box and type What does the number 125 on the<br />

camera indicate?<br />

6 In the first Responses text box, type Shutter speed. Then select Correct, to the right of<br />

the text box.<br />

7 Verify that Case Sensitive is not selected and Exact Match is selected.<br />

8 Click Options, at the bottom of the panel. To give the user two chances to answer the question<br />

correctly, type 2 in the Tries text box.<br />

When you give the user more than one chance to answer the question correctly, feedback<br />

specified in the Additional Tries text box appears if the user first answers incorrectly.<br />

9 Select the text in the Additional Tries text box and type Incorrect. Please try again.<br />

110<br />

Chapter 4


10 Change the text in the other feedback text boxes, as desired. For example, you can select the<br />

text in the Correct Feedback text box and type Yes! You’re right!<br />

Arrange text and graphics<br />

To give the interaction a consistent look, you’ll modify the text fields, move the graphic<br />

representation of the input text field, and add an image to the interaction.<br />

1 With Frame 3 of the Interactions layer selected, use the Pointer tool to select the Your<br />

Question Will Appear Here text. As you did with the previous interaction, make the text 14-<br />

point Arial bold. Give the text an x coordinate of 10.7 and a y coordinate of 14.5.<br />

2 On the Stage, select the instance of Field_Background, with the text that states “Enter your<br />

answer here,” and place it so that x = 11.1 and y = 45.1.<br />

Drag input text field to this location<br />

Input text field<br />

3 The actual input text field appears on the Stage bounded by dotted lines. Drag the input field<br />

within the Field_Background instance.<br />

Introduction to Learning Interactions Tutorial 111


4 Drag Camera_top.png from the Images folder in the LearningAssets.fla library to the Stage.<br />

Place the image below the input text field.<br />

5 Drag 125_glow.png from the images folder in the LearningAssets.fla library to the Stage. Place<br />

the image over 125 on the camera’s shutter speed selector.<br />

Note: As you complete the tutorial, remember to test and save your work frequently.<br />

Modify a Multiple Choice interaction<br />

To modify the Multiple Choice component, you’ll add the question text and the answer text, and<br />

specify which answer is correct.<br />

1 In the Timeline, select Frame 4 on the Interactions layer. On the Stage, verify that objects on<br />

the layer are selected, and choose Modify > Break Apart. Then press Control+Shift+A or click<br />

an empty space in the workspace.<br />

2 Select the Multiple Choice component. If the Component Parameters panel isn’t open, launch<br />

it from the Property inspector.<br />

3 Select the text in the Question text box and type Which camera part affects the amount of<br />

light that passes through the lens?<br />

4 In the Label text box for Checkbox 1, select Apple and type Shutter speed. Click the check<br />

mark under Correct to deselect it, which indicates that the choice is now an incorrect answer.<br />

5 In the Label text box for Checkbox 2, select Zucchini and type Film advance lever. Do not<br />

click the Correct check box to the right of the text box.<br />

6 In the Label text box for Checkbox 3, select Tomato and type Aperture. Verify that Correct is<br />

selected the right of the text box, to indicate that this is a correct answer.<br />

7 In the Label text box for Checkbox 4, select Potato and type Film counter. Do not click the<br />

checkbox under Correct.<br />

112<br />

Chapter 4


8 You will have four choices, instead of the five that the template provides. To delete the last<br />

choice, select Checkbox 5 in the Instance Name category and press Delete or Backspace.<br />

9 If desired, click Options at the bottom of the panel and change the correct and incorrect<br />

feedback text. The user will have one try to answer the question correctly; you do not need to<br />

change the Additional Tries feedback text, because that text will not appear to the user.<br />

Arrange text and graphics<br />

You’ll modify the question text, delete one of the answers, and add an image to the interaction.<br />

1 On the Stage, use the Pointer tool to select the Your Question Will Appear Here text. Use the<br />

Property inspector to make the text Arial 14-point bold, with x and y coordinates of 10.7 and<br />

14.5, respectively.<br />

2 Select and delete the instance of Checkbox5 (Label E).<br />

3 Select the Label A component (Checkbox1). Press Shift and click the Label B through D<br />

objects to add them to the selection. In the Property inspector, select the text in the Width (W)<br />

text box and type 160 to resize the choice labels, then press Tab.<br />

4 Drag the four selected labels to just below the question text.<br />

Introduction to Learning Interactions Tutorial 113


5 Drag Camera2.png from the Images folder in the LearningAssets.fla library to the Stage,<br />

placing the image slightly to the right of the four choice labels.<br />

About graphic distractors<br />

The Drag and Drop, Hot Object, and Hot Spot interactions use placeholder instances. To change<br />

the appearance of the interaction, you can either delete the existing instances and register new<br />

instances, or you can replace or modify the symbols.<br />

If you’ll use a graphic interaction more than once in the Timeline, or if you don’t want to change<br />

the interaction movie clip that exists in the library, you must follow a process that deletes the<br />

existing instances and names and registers instances of new movie clips. The original interaction<br />

remains unchanged in the library, and available for use again. In this tutorial, you’ll follow this<br />

process with the Drag and Drop interaction.<br />

If you know that you will not use the same type of graphic interaction more than once in your<br />

movie, you can replace the existing movie clips with movie clips that have exactly the same name.<br />

The interaction reflects the changes and updated art. In this tutorial, you’ll follow this process<br />

with the Hot Object interaction.<br />

You can also edit the movie clip symbol. You’ll follow this process for the Hot Spot interaction.<br />

Modify a Drag and Drop interaction<br />

The Drag and Drop interaction lets users drag objects to targets. The component lets you specify<br />

the question and the unique names of the Drag objects and Target objects.<br />

1 In the Timeline, select Frame 5 on the Interactions layer.<br />

2 On the Stage, verify that objects on the layer are selected, and choose Modify > Break Apart.<br />

Press Control+Shift+A or click an empty space in the workspace to deselect the objects.<br />

3 On the Stage, select Drag1, then press Shift and also select Drag2 through 4, and Target1<br />

through 4. Press Backspace or Delete to delete all Drag and Target objects from the Stage.<br />

4 Select the Drag and Drop component to the left of the Stage. If the Component Parameters<br />

Panel isn’t open, launch it from the Property inspector.<br />

5 Select the text in the Question text box and type Drag the photo to the correct exposure setting.<br />

6 In the Drag Object Name and Matches Target Name categories, select and delete the Drag4<br />

and Target4 text; your quiz will have three Drag objects and three Target objects only.<br />

114<br />

Chapter 4


7 In the Drag Object Name and Matches Target Name categories, type the letter N, for new, at<br />

the end of each name.<br />

You’re registering the unique instance name that you will give to your replacement instances.<br />

8 To specify that Drag objects snap to a target, verify that Snap to Start is selected.<br />

Arrange text<br />

You’ll give the question text the same attributes that you specified in previous frames.<br />

• On the Stage, use the Pointer tool to select the question text. Use the Property inspector to<br />

make the text Arial 14-point bold, with x and y coordinates of 10.7 and 14. 5, respectively.<br />

Introduction to Learning Interactions Tutorial 115


Assign instance names to the new drag symbols<br />

You’ll place the new drag symbols in the LearningAssets.fla library, and give them the same<br />

instance names in the Property inspector that you specified in the Component Parameters panel.<br />

1 From the LearningAssets.fla library, go to 2_Learning Interactions > 0_Assets > DragDrop folder,<br />

and drag DD_D3 toward the upper left area of the Stage, as shown in the following illustration.<br />

2 Place DD_D1 next to it, then DD_D2 at the end of the row.<br />

3 On the Stage, select DD_3. In the Property inspector, enter Drag3N in the Instance<br />

Name text box.<br />

4 On the Stage, select DD_1. Use the Property inspector to give it the instance name of<br />

Drag1N.<br />

5 On the Stage, select DD_2. Use the Property inspector to give it the instance name of<br />

Drag2N.<br />

116<br />

Chapter 4


Assign instance names to the new target symbols<br />

Now you’ll follow a process similar to the one you just used for the drag symbols to drag the new<br />

target symbols from the LearningAssets.fla library, and give them the same instance names in the<br />

Property inspector that you specified in the Component Parameters panel.<br />

1 From the LearningAssets.fla library, go to 2_Learning Interactions > 0_Assets > DragDrop folder,<br />

and drag DD_T1 toward the lower left area of the Stage, as shown in the following illustration.<br />

2 Place DD_T2 next to it, then DD_3 at the end of the row.<br />

3 On the Stage, select DD_T1. In the Property inspector, select the text in the Instance Name<br />

text box and type Target1N.<br />

4 On the Stage, select DD_T2. Use the Property inspector to give it the instance name of<br />

Target2N.<br />

5 On the Stage, select DD_T3. Use the Property inspector to give it the instance name of<br />

Target3N.<br />

Introduction to Learning Interactions Tutorial 117


Align Drag objects and Target objects<br />

To align the Drag objects and Target objects, you’ll use the Align panel.<br />

1 On the Stage, using the Pointer tool, click DD_D3, then Shift-click to also select DD_D1<br />

and DD_D2.<br />

2 If the Align panel isn’t open, choose Window > Align.<br />

3 Verify that To Stage is not selected, and click Align Vertical Center and Distribute Horizontal<br />

Center. Press Control+Shift+A or click an empty area in the workspace.<br />

4 On the Stage, click DD_T1, then Shift-click to also select DD_T2 and DD_T3. Click Align<br />

Vertical Center and Distribute Horizontal Center.<br />

View the Drag and Drop movie clip in the Library panel<br />

• In the MyQuiz (not LearningAssets.fla) library, select the Drag and Drop movie clip in the<br />

2_Learning Interactions folder.<br />

The symbols remain unchanged; you can use the interaction again, if desired.<br />

Modify a Hot Object interaction<br />

To modify a Hot Object interaction, you first modify the component to specify the question text,<br />

and you specify the object that will register as a correct choice when clicked.<br />

1 In the Timeline, select Frame 6 on the Interactions layer.<br />

2 On the Stage, verify that all objects on the layer are selected and choose Modify ><br />

Break Apart. Deselect all selected objects by pressing Control+Shift+A or clicking an<br />

empty area in the workspace.<br />

3 Select the Hot Object component. If the Component Parameters panel isn’t open, launch it<br />

from the Property inspector.<br />

4 Select the text in the Question text box and type Click the part of the camera you would press<br />

to take a picture.<br />

5 Select Correct for HotObject1, and deselect Correct for HotObject4.<br />

When users click the HotObject1 area, the response will register as correct.<br />

118<br />

Chapter 4


Arrange text<br />

You’ll give the question text the same attributes that you specified with previous interactions.<br />

• On the Stage, use the Pointer tool to select the question text. Use the Property inspector to<br />

make the text Arial 14-point bold, with x and y coordinates of 10.7 and 14. 5, respectively.<br />

Replace hot object images<br />

Although you can delete and register instances using the same process that you used with the<br />

Drag and Drop interaction, you’ll use a different process for the Hot Object interaction. Instead,<br />

you will replace existing movie clips with new ones that have the same name. Because this process<br />

changes all instances of the symbols, it works best when you know you’ll use the interaction type<br />

only once in a document.<br />

1 In the LearningAssets.fla library, drag HO_Object1 from the 2_Learning Interactions/<br />

0_Assets/HotObjects folder to any place on the Stage or in the workspace.<br />

HO_Object1 has the same name as a symbol that already exists in the template (MyQuiz) library.<br />

2 In the Resolve Library Conflict dialog box, select Replace Existing Items (not undoable),<br />

and click OK.<br />

The original movie clip reflects the replacement, and the instance that you dragged onto the<br />

Stage is still selected.<br />

3 Press Delete or Backspace to delete just the instance that you dragged onto the Stage.<br />

4 In the LearningAssets.fla library, drag HO_Object2 from the 2_Learning Interactions/<br />

0_Assets/HotObjects folder to anyplace on the Stage or in the workspace.<br />

5 In the Resolve Library Conflict dialog box, select Replace Existing Items (not undoable),<br />

and click OK.<br />

6 Press Delete or Backspace to delete just the instance that you dragged onto the Stage.<br />

7 Repeat steps 4–6 to use assets in the LearningAssets.fla library (in the 2_Learning Interactions/<br />

0_Assets/Hot Objects folder) to drag HO_Object3, HO_Object4, HO_Object5 and<br />

HO_Object6 to the Stage, then delete the instance that you just dragged.<br />

Introduction to Learning Interactions Tutorial 119


View the Hot Object interaction in the Library panel<br />

• In the MyQuiz (not LearningAssets.fla) library, select the Hot Objects movie clip in the<br />

Learning Interactions folder.<br />

With the Drag and Drop interaction, the symbols did not change. The process that you used<br />

for the Hot Object interaction replaces the symbols in the library.<br />

To follow the process you used for replacing Hot Object movie clips, remember that you must<br />

create movie clip symbols, in a separate FLA file, that have the same name as the movie clip<br />

symbols that you want to replace. You can then open the separate FLA file as a library. You can<br />

drag the instance of the new symbol to the Stage to replace the original symbol. You then delete<br />

the instance that you just dragged. You can also simply drag the new symbol to the library in<br />

which you will replace the original symbol.<br />

Change the color of a selected hot object<br />

When the user selects a hot object, the object, by default, changes to light red to let the user know<br />

that the object is clicked. You can change the default color in the Actions panel. You’ll change the<br />

“clicked” color from red to blue.<br />

1 In your MyQuiz library, go to 2_Learning Interactions/2_Components, and double-click<br />

2_HotObjects to enter symbol-editing mode.<br />

2 In the 02_HotObjects Timeline, click Frame 1 on the Actions layer. Then open the Actions<br />

panel (Window > Actions).<br />

3 If you’re not in normal mode, click the options menu control on the right side of the title bar<br />

and select Normal Mode.<br />

4 Open the options menu again and select Go to Line. In the dialog box, type 42 and click OK.<br />

Note: For the correct line to be selected, you must not have auto-format options selected for the Actions panel. If<br />

the transform.rb line of ActionScript is not selected, choose Auto Format Options from the Actions panel options<br />

menu, and deselect any selected options.<br />

This section of ActionScript lets you select red, green, and blue values for the color object.<br />

While you can experiment with the value numbers to specify a color, we’ve already come up<br />

with values that create blue. For more information about what each line of code controls,<br />

search for topics on the Color Object and the setTransform Object in <strong>Flash</strong> Help (Help ><br />

Using <strong>Flash</strong> and Help > ActionScript Dictionary).<br />

5 In the Value text box, enter 0.<br />

If the Expert Mode Warning dialog box appears, click OK,<br />

6 Select line 44 and enter 51 in the Value text box.<br />

120 Chapter 4


7 Select line 46 and enter 102 in the Value text box, then close the Actions panel.<br />

8 Choose Edit > Edit Document.<br />

Tip: As you complete the tutorial, remember to test and save your work frequently.<br />

Modify a Hot Spot interaction<br />

To modify the Hot Spot component, you type the hot spot question, then specify which hot spot<br />

area, when clicked, will register as a correct response.<br />

1 In the Timeline, select Frame 7 on the Interactions layer. On the Stage, verify that all objects<br />

on the layer are selected, and choose Modify > Break Apart. Then press Control+Shift+A or<br />

click an empty space in the workspace.<br />

2 Select the Hot Spot component. If the Component Parameters panel isn’t open, launch it from<br />

the Property inspector.<br />

3 Select the text in the Question text box and type Click the part of the camera that advances<br />

the film.<br />

4 Select Correct for HotSpot6, and deselect Correct for HotSpot4.<br />

A user click on HotSpot6 will now register as a correct answer.<br />

5 Select the text in the Up State Alpha text box and type 0.<br />

The Up State Alpha text box indicates the level of transparency for the hot spot before the user<br />

clicks it. In your quiz, you’re specifying that the hot spot is initially invisible. The Down Alpha<br />

State indicates the level of transparency for the hot spot, once the user clicks it. By accepting<br />

the default setting of 100, you’re specifying that the hot spot will be displayed once it is clicked,<br />

which offers visual feedback to the user.<br />

Introduction to Learning Interactions Tutorial 121


Arrange text<br />

You’ll give the question text the same attributes that you specified in previous frames.<br />

• On the Stage, use the Pointer tool to select the question text. Use the Property inspector to<br />

make the text Arial 14-point bold, with x and y coordinates of 10.7 and 14. 5, respectively.<br />

Add a hot spot image<br />

Users click hot spot areas that overlay an image. You’ll add that image now.<br />

1 On the Stage, select the instance of Image_Area: the rectangular border that surrounds the hot<br />

spot areas. Refer to the Property inspector to verify that you’ve selected the correct instance,<br />

and press Backspace or Delete.<br />

Image_Area instance<br />

2 With Frame 7 of the Interactions layer selected, drag Camera_top.png from the images folder<br />

in the LearningAssets.fla library, placing it in the approximate center of the Stage.<br />

In the Property inspector, you can specify the x and y coordinates for the image that the<br />

finished file uses: x = -5.5 and y = 70.8.<br />

3 On the Interactions layer, the image covers the hot spot areas. To change the stacking order of<br />

objects on the layer so that the hot spot areas cover the image instead, verify that<br />

Camera_top.png is still selected, and choose Modify > Arrange > Send to Back.<br />

The hot spot areas now appear over the camera image.<br />

122<br />

Chapter 4


4 On the Stage, use the Pointer tool to drag the instance of HS_Area6 to cover the film advance lever.<br />

5 With the Pointer tool, continue to select and place hot spot areas over the camera, as follows:<br />

• Place the instance of HS_Area3 so that it covers the shutter release.<br />

Note: It does not matter that the Hot Spot area is larger than the shutter release. The size of the Hot Spot areas<br />

will change when you add images to the Hot Spot symbols.<br />

• Place the instance of HS_Area5 so that it covers the shutter speed selector.<br />

• Place the instance of HS_Area2 so that it covers the lens.<br />

Introduction to Learning Interactions Tutorial 123


• Place the instance of HS_Area4 so that it covers the aperture.<br />

• Place the instance of HS_Area1 so that it covers the film rewinder.<br />

Add an image within a hot spot area<br />

When the user clicks a hot spot area, visual feedback should let the user know that the clicked area<br />

is selected. You’ll provide that feedback by adding “glow” images that initially have an alpha<br />

transparency of 0, as specified in the component parameters, but become opaque in the movie<br />

upon a mouse click. To add the images, you delete and replace the images within each hot spot<br />

movie clip.<br />

1 On the Stage, double-click HS_Area1. In symbol-editing mode, use the Pointer tool to select<br />

the graphics by dragging from above the upper left corner to below the lower right corner of<br />

the group, selecting all graphics in the movie clip. Press Backspace or Delete.<br />

2 From the Images folder in the LearningAssets.fla library, drag rewind_glow.png and place it<br />

within HS_Area1 so that the “glow” outlines the film rewinder.<br />

Note: The bounding box reflects the new hot spot area.<br />

124<br />

Chapter 4


3 Click Scene 1, above the Stage.<br />

4 On the Stage, double-click HS_Area2. In symbol-editing mode, use the Pointer tool to drag<br />

around the hot spot graphics, selecting all the graphics as you did in step 1. Then press<br />

Backspace or Delete.<br />

5 From the Images folder in the LearningAssets.fla library, drag lens_glow.png and place it<br />

within HS_Area2 so that the “glow” outlines the lens. Then click Scene 1, above the Stage.<br />

6 Repeat steps 4 and 5 to open a hot spot in symbol-editing mode, delete the existing group of<br />

graphics, then drag and position the corresponding glow image from the Images folder in the<br />

LearningAssets.fla library, as follows (remember to click Scene 1 when you’ve finished with a<br />

hot spot):<br />

• For HS_Area3, use Shutter_glow.png. Place the glow image around the shutter release button.<br />

• For HS_Area4, use Aperture_glow.png. Place the glow image around the aperture.<br />

• For HS_Area5, use Shutter_speed_glow.png. Place the glow image around the shutter<br />

speed selector.<br />

• For HS_Area6, use Advance_glow.png. Place the glow image around the film advance lever.<br />

Introduction to Learning Interactions Tutorial 125


Add an interaction to the Timeline<br />

To add an interaction to the Timeline, you add frames across all layers in the Timeline. You can<br />

then either use an interaction from the library or use the streamlined process that you’ll follow<br />

now, to copy the interaction from one frame to another.<br />

1 In the Timeline, select Frame 7 on the top layer, the Instructions layer. Shift-select Frame 7 on<br />

all the layers below the Instructions layer.<br />

2 Right-click (Windows) or Control-click (Macintosh) a selected frame and choose Insert Frame<br />

from the context menu.<br />

The Timeline extends evenly across all layers.<br />

3 Select Frame 8 on the Interactions layer and choose Insert > Blank Keyframe.<br />

4 Select Frame 3 on the Interactions layer, and choose Edit > Copy Frames.<br />

5 Select Frame 8 on the Interactions layer and choose Edit > Paste Frames.<br />

A copy of the Fill in the Blank interaction appears on the Stage.<br />

6 Deselect all selected objects, then select and delete the camera image and the “glow” image.<br />

126<br />

Chapter 4


Arrange text and graphics<br />

You’ll now arrange text and graphics on the Stage, just as you did for the first Fill in the<br />

Blank interaction.<br />

1 Verify that Frame 8 on the Interactions layer is still selected. From your MyQuiz library, drag<br />

Camera1.png to the Stage. Place the image below the input text field, as shown in the<br />

following illustration.<br />

2 To the left of the Stage, select the Fill in the Blank component. Launch the Component<br />

Parameters panel, if necessary.<br />

3 Select the text in the Question text box and type What mechanism opens to allow light to<br />

enter through the camera lens?<br />

4 In the first Responses text box, type Shutter. Then select Correct to the right of the text box.<br />

5 Verify that Case Sensitive is not selected, and Exact Match is selected.<br />

6 Click Options, at the bottom of the panel, and verify that 2 is entered in the Tries text box.<br />

Change the feedback text, as desired.<br />

Modify the quiz results<br />

The last frame in the template displays the quiz results. You can modify text in the quiz results<br />

frame, and add graphics, but you should not change the names of the dynamic text fields, or the<br />

results will not appear. Additionally, do not add interactions to the frame containing quiz results.<br />

1 In the Timeline, select Frame 9 on any layer, then use the Pointer tool to select just the Quiz<br />

Results text on the Stage.<br />

2 Using the Property inspector, make the text 14 point Arial bold, with an x coordinate of 10.7<br />

and a y coordinate of 14.5.<br />

3 Select the Line tool. In the Property inspector, verify that 1 is selected for the stroke height, and<br />

Solid is selected for the stroke style. Hold Shift, while drawing a horizontal line from the lower<br />

edge of the “s” in “Results,” to end just before the edge of the Stage.<br />

4 In the toolbox, select the Rectangle tool. Open the Color Mixer (Windows > Color Mixer),<br />

if necessary.<br />

Introduction to Learning Interactions Tutorial 127


5 In the Color Mixer, select Solid as the fill style. Select the blue stroke color of #0099FF. Select<br />

a white fill color of #FFFFFF, with an alpha value of 20%.<br />

You can either find the color chip with the specified value, or type the hexadecimal value<br />

directly in the text box.<br />

6 Verify that you’re in Frame 9 on the Interactions layer. On the Stage, draw a rectangle that<br />

encloses the score.<br />

7 To group the rectangle fill with its stroke, use the Pointer tool to double-click inside the<br />

rectangle, and choose Modify > Group.<br />

8 In the Align panel (choose Window > Align if the panel is not open), select To Stage, then click<br />

Align Vertical Center and Align Horizontal Center.<br />

Note: All the assets that you used from the LearningAssets.fla library are now part of your MyQuiz library. You’ve<br />

finished modifying the interactions; this would be a good time to organize your MyQuiz library. For example, you can<br />

create an Images folder for the PNG files.<br />

128<br />

Chapter 4


Publish the quiz for AICC Tracking<br />

<strong>Flash</strong> quiz templates allow communication with both AICC- and SCORM-compliant learning<br />

management systems. Code built into the <strong>Flash</strong> document and the HTML file created during the<br />

publish process sends formatted data, including the score and time spent taking the quiz, to the LMS.<br />

For an overview of the AICC and SCORM communication process, see <strong>Flash</strong> Help (Help ><br />

Using <strong>Flash</strong> > Creating E-learning Content).<br />

1 Choose File > Publish Settings.<br />

2 In the Publish Settings dialog box, verify that <strong>Flash</strong> (.swf) and HTML are selected in the<br />

Formats panel.<br />

3 On the HTML tab of the Publish Settings dialog box, select the <strong>Flash</strong> w/AICC Tracking<br />

template, then click Publish and close the dialog box.<br />

The publish process creates a <strong>Flash</strong> SWF file and HTML file, which are saved in the same<br />

directory as the FLA file. You can open the MyQuiz.html file in a browser to see how your quiz<br />

appears in a web page.<br />

Other tracking processes<br />

To continue configuring your quiz for AICC tracking, you would complete the following process.<br />

1 Place the <strong>Flash</strong> SWF file and HTML file that you just created on the web server, with both files<br />

in the same directory.<br />

2 In your Macromedia <strong>Flash</strong> <strong>MX</strong> application folder, browse to First Run/HTML/Learning<br />

Extensions Srvr Files. Within the folder, copy frameset.htm, result.htm, and the scripts<br />

subfolder to the same web server directory where you copied the SWF and HTML files that<br />

you published.<br />

3 In a text editor, open the copy of frameset.htm. In the second line of text, change Untitled-1<br />

to the name of your HTML file, which should be MyQuiz.html.<br />

4 Either launch your LMS or create the AICC Course Descriptor Files that reference the<br />

frameset.htm file.<br />

Moving on<br />

To learn more about creating instructional media with <strong>Flash</strong>, visit the Macromedia <strong>Flash</strong> Support<br />

Center at http://www.macromedia.com/support/flash/.<br />

Introduction to Learning Interactions Tutorial 129

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!