• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 15. Introducing Complex Interact... > Changing the Properties of Objects

Changing the Properties of Objects

An object that you are already familiar with is the movie clip. All its defining characteristics—height, width, transparency, and so on—are called its properties. When you are authoring a movie, you can change these characteristics with Flash’s drawing tools, but ActionScripts let you modify an object’s properties during playback.

To script a button that makes a movie clip invisible:

Create a new Flash document, and place an instance of a movie clip and a button on the Stage in Keyframe 1.

On the Stage, select the movie clip instance.

In the Property Inspector’s Instance Name field, enter a name for the instance, such as starMC1 (Figure 15.1).

Figure 15.1. To make a movie clip the target of ActionScript, you must give the clip an instance name in the Property Inspector.

On the Stage, select the button instance.

In the Property Inspector’s Instance Name field, enter hideBTN.

In the Actions-Button panel, from the Add menu, choose Actions > Movie Control > on.

Flash adds the button handler to the Script pane.

With the handler (Line 1 of the script) selected, in the Actions Toolbox, double-click Actions > Movie Clip Control > setProperty (Figure 15.2).

Figure 15.2. You can create a button script that will control your movie clip by choosing actions from the Actions> Movie Clip Control category in the Actions Toolbox (shown) or from the Add menu.

Flash adds the setProperty action to Line 2 in the Script pane and displays fields for entering the appropriate parameters.

From the Property pop-up menu, choose _visible (Visibility) (Figure 15.3).

Figure 15.3. In Normal mode, the parameters area of the Actions panel offers a pop-up menu of properties that you can set for movie-clip objects when you add setProperty to a script. Visibility controls whether viewers can see the movie clip.

The _visible property has two possible states (or values): true (the object is visible) or false (the object is disabled and hidden).

Terminology: Expressions and Variables

Expressions and variables go hand in hand. If creating ActionScripts were like cooking, expressions would be the recipes, and variables would be the bowls, cups, pans, and other containers. The values would be the ingredients that you place in the containers.

The recipe/expression might say, “Combine the contents of the red bowl and the green bowl, and put it in the blue pan.” If you put eggs in the red bowl and milk in the green bowl, you’l get one dish. If you put tomatoes in the red bowl and pasta in the green bowl, you’l get quite another. Although the containers are the same, and although the instructions for combining their contents are the same, the variety of the contents makes for different results.

When you create a movie clip and place it on the Stage, its default visibility is true. To script a button that hides the clip, you must set the clip’s visibility to false.

In the Target field, enter the instance name of the movie clip, starMC1.

This parameter tells Flash which object you want to perform the action on.

In the Value field, enter false, and check the Expression checkbox.

Checking the Expression checkbox tells Flash to interpret what you enter in the Value field as a description of the value, not as a set of the particular letters f, al, l, s, and e (Figure 15.4).

Figure 15.4. By setting the parameters of the setProperty action, you tell Flash which object to manipulate and what to do with it. Here, setting the visibility property of the starMC1 movie clip to false will hide the movie clip.

Choose Control > Test Movie to try out your button.

When you click the button, the movie clip disappears.



Not a subscriber?

Start A Free Trial

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