Introduction to ActionScript Tutorial > Initialize the movie > Set movie clip properties

 

Set movie clip properties

The puzzle.fla movie has three dialog boxes: one alerts you when the puzzle is completed, and the other two ask if you want to scramble the puzzle pieces. Additionally, several patterns and guides overlay the solution area to help users solve the puzzle. Each of these dialog boxes, patterns, and guides is a movie clip.

To initialize the movie, you must hide several of the movie clips so that only the start dialog box and the puzzle pieces are showing. You'll do this by setting their _visible properties to false.

1

Select Frame 1 in the Actions layer. If the Actions panel isn't open, choose Window > Actions.

The Actions panel shows actions associated with the selected frame. Text after double slashes (//) is commented text, which offers information helpful in understanding the scripts.

2

Click the pop-up menu in the upper right corner of the Actions panel title bar. Verify that Normal Mode and View Line Numbers are selected.

3

In the Script pane, click line 4 to select the commented code that reads //ENTER code here.

4

From the Actions > Miscellaneous Actions category in the Actions toolbox on the left, double-click the evaluate action to add an empty line of code ending with a semicolon.

A semicolon (;) in an ActionScript statement is like a period (.) in an ordinary sentence.

5

With the insertion point in the Expression text box of the Actions panel, click the Insert Target Path button.

The Insert Target Path dialog box appears.

6

Verify that Dots, meaning dots notation, and Absolute, meaning absolute path, are selected.

In the dialog box, you see a list of movie clips from which you can select.

7

Select the edges movie clip from the movie clip tree, then click OK.

The following code appears in the Expression text box:

_root.edges

A target path tells ActionScript the location of a movie clip within the overall structure of a Flash movie. The _root property refers to the main Timeline and the edges movie clip lives on the Stage of the main Timeline. Any target path that begins with _root is called an absolute path because it gives the complete path to a movie clip from the main Timeline.

8

With the insertion point after _root.edges, enter ._visible = false in the Expression text box.

This line of code makes the movie clip invisible on the Stage.

You can type the code manually, or you can choose ActionScript items from the Properties and Operators folders in the Actions toolbox.

If you make an error entering an action and decide you'd like to delete it, select the action in the Script pane and click the Minus (-) button in the Actions panel.

9

In the Actions toolbox, again double-click the evaluate action to add an empty line of code ending with a semicolon. Repeat steps 5 and 6, then choose the pattern movie clip in the Insert Target Path dialog box. Repeat Step 8, again typing ._visible = false in the Expression text box.

10

Continue to repeat steps 4 through 8, choosing the image, piecenumbers, scramblebutton, areYouSure, and congrats movie clips in the Insert Target Path dialog box, and typing ._visible = false for each movie clip.When you finish, your script should appear as follows:

11

Choose File > Save As and enter a new filename. Use a consecutive naming scheme, such as mypuzzle3.fla, so you can revert to earlier versions of the file, if necessary.