CHANGING THE HEIGHT OF MOVIE CLIPS USING FLASH



You can use the _height property to set the distance from the bottom of a movie or movie clip to the top in pixels. This property is useful if you need to resize a movie or movie clip as the movie plays. You can increase or decrease the height of a movie or movie clip. A possible use of the _height property is to increase or decrease the size of a bar as the user increases or decreases the sound volume. Alternatively, you may want to use the _height property to give the user the ability to set the size of objects on the Stage.

Before you can change the _height property of a movie clip instance, the movie clip instance must have a name. You can use the Instance panel to name a movie clip instance. The syntax for the _height property is

instanceName._height = value;

The instanceName argument is used to specify the name of the movie clip instance for which you want to change the _height property. To change the height of the movie, omit the InstanceName argument. Use the value argument to set the value of the _height property of the movie or movie clip in pixels.

ActionScript also provides you the ability to retrieve the current value of the _height property. As with other properties, you can retrieve the _height property and use the value to check what action to perform next. The syntax for retrieving the _height property is

instanceName. _height;

Use the instanceName argument to specify the name if the movie clip for which you want to retrieve the _height property. Omit the instanceName argument to retrieve the height of the movie.

Follow the below steps:

1) Select the frame, button, or movie clip to which you want to add ActionScript.

This example uses a button.

2) Click Window from menu bar and then click on Actions to open the Actions panel.

3) Click Properties to open the Properties category.

4) Double-click _height to select the _height property.

5) The default handler on(release) appears in the Action list.

6) The _height property appears in the Action list.

7) Set the _height property for a movie clip instance.

8) The instance name precedes the property name.

9) The value follows the property name.

10) Move to the test environment.

11) Click the button to test your movie.

12) The size of the movie clip instance changes to the height you set.



You can use the below script to increase the height of a movie clip each time the user clicks on a button. The script retrieves the height of a movie clip named block and assigns the value to a variable named heightV. It then sets the height of the block movie clip to the value of heightV plus 10. You can use the setProperty action to set the height of a movie clip.

Example:

on (release) {
heightV = block._height;
setProperty ("block", _height, heightV + 10);
}


OUTPUT:

Each time the user clicks a button, the height of the movie clip increases by 10 pixels.