Lesson 2

Work with Targets and Movie Clip Symbols

 

OBJECTIVE:

In this lesson, you will use ActionScript to control movie clip Timelines.

Sample Solution

Lesson:  Assign an instance name to a movie clip symbol

  1. Open fl9_2.fla, then save it as 'shirt' to your Flash C9 folder in your server folder
  2. Click the Selection tool (on the Tools panel), then double-click the yellow shirt on the Stage to open the shirt_color movie clip symbol—the yellow shirt on the Stage is an instance of the shirt_color movie clip—this movie clip symbol has a layer (shirt) that changes the color of the shirt, a layer (actions) that includes actions to stop the clip after each frame, and a layer (pattern) that includes a nested movie clip to change the pattern of the shirt—when you double-click the shirt, you are displaying the movie clip in an edit window
  3. Drag the playhead along the movie clip Timeline to see how the shirt changes color, then click Scene 1 at the top left of the workspace to return to the main Timeline
  4. Click the shirt on the Stage to select it
  5. Display the Properties panel, then verify shirt_color is displayed after the phrase Instance of—this indicates that the shirt is an instance of the shirt-color movie clip, which is available in the Library panel
  6. Click the Instance Name text box, type myShirt for the instance name, then press Enter—the shirt on the Stage is an instance of the movie clip shirt_color—specifying an instance name is required when you want to target the movie clip in your ActionScript

Summary:  You viewed a movie clip in the edit window and then assigned an instance name to the movie clip.

 

Lesson:  Use Script Assist to control the Timeline of a movie clip symbol

  1. Click the red button on the Stage (under the words “Click to Pick a Color”), display the Actions panel, then verify the push button red button symbol is displayed in the lower left of the Script pane
  2. Click Script Assist to turn it on
  3. Click the 'Add a new item to the script' button, point to Global Functions, point to Movie Clip Control, then click 'on'
  4. Click the 'Add a new item to the script' button, point to Statements, point to Variable, then click 'with'—now you need to specify the movie clip to be targeted with the action
  5. Click inside the Object text box, click the Insert a target path button to open the Insert Target Path dialog box, scroll the list, click the myShirt movie clip instance symbol, then click OK
  6. Click the 'Add a new item to the script' button, point to Global Functions, point to Timeline control, then click 'goto'
  7. Click the Type list arrow, click 'Next Frame'
  8. Test the movie, then click the red button repeatedly—each time you click the button, the shirt color changes
  9. Close the Flash Player window, then collapse the Actions panel

Summary:  You used Script Assist to write ActionScript code to control the Timeline of a movie clip symbol.

 

Lesson:  Use Script Assist to control the Timeline of a nested movie clip symbol

  1. Verify that the Selection tool  is selected, double-click the shirt on the Stage, double-click the shirt (now in the edit window) to open the pattern_shirt nested movie clip symbol—the pattern_shirt movie clip symbol (nested inside the shirt_color movie clip symbol) changes the pattern of the shirt—it includes two frame labels, “circles” and “stars”
  2. Drag the playhead along the movie clip symbol Timeline to see how the shirt pattern changes
  3. Click the shirt_color movie clip link at the top of the workspace to return to the shirt_ color edit window
  4. Click the shirt on the Stage to select an instance of the pattern_shirt mobie clip symbol, display the Properties panel, click the Instance Name text box, type 'myPattern' for the instance name, then press Enter
    [TIP:  The Properties panel changes the settings for the currently selected object, the pattern_shirt movie clip—to select a nested movies clip, the parent movie clip must be open]
  5. Click Scene 1 at the top left of the workspace to return to the main Timeline
  6. Click the Stars button on the Stage (under the word “Patterns”) to select the Stars button
  7. Display the Actions panel, then verify that the Stars button symbol is displayed in the lower left of the Script pane
  8. Click the 'Add a new item to the script' button, point to Global Functions, point to Movie Clip Control, then click 'on'
  9. Click the 'Add a new item to the script button', point to Statements, point to Variables, then click 'with'
  10. Click inside the Object text box, click the Insert a target path button, click the plus button to expand the myShirt path, click the myPattern movie clip symbol, then click OK—a path (this.myShirt.my Pattern) is inserted into the nested movie clip symbol in dot syntax format
  11. Click the 'Add a new item to the script button', point to Global Functions, point to Timeline control, then click 'goto'
  12. Click the Type list arrow, click Frame Label, click in the Frame text box, delete the frame number, type 'stars' in the Frame text box
  13. Test the movie, then click the Stars button—the shirt pattern changes to stars
  14. Close the Flash Player window, then save your work

Summary:  You used Script Assist to create ActionScript code to control the Timeline of a nested movie clip symbol.

 

Lesson:  Copy ActionScript between objects

  1. Turn off Script Assist—turning off Script Assist allows you to edit the code
  2. Right-click in the Script pane, then click Select All to select the ActionScript
  3. Right-click the selection, then click Copy
  4. Click the Circles button on the Stage to select it, then verify circles and the button symbol are displayed in the lower left of the Script pane
  5. Click in the Script pane, right-click, then click Paste
  6. Double-click the word 'stars' in the Script pane to select it, press Delete, then type circles
  7. Test the movie, click the Stars button, then click the Circles button—the shirt pattern changes to stars when you click the Stars button, the shirt pattern changes to circles when you click the Circles button
  8. Close the Flash Player window, close the Actions panel, save your work, then close the document

Summary:  You copied and edited ActionScript code.