Working with Movie Clips and Buttons > Manipulating buttons with ActionScript

 

Manipulating buttons with ActionScript

Each button in a Flash movie is an ActionScript object of the class Button and has its own properties and methods. Buttons have the same properties as movie clips, but several properties (_currentframe, _droptarget, _framesloaded, and _totalframes) are not supported and return the value undefined. The Button class has two additional properties: useHandCursor, which lets you decide whether the cursor turns into a hand when it passes over a button, and enabled, which lets you specify whether the button is active or not.

You can give a button an instance name in the Property inspector and use a target path to manipulate it with ActionScript. To write a target path for a button instance, write the target path to the movie clip in which the button is located, and add a dot (.) and the instance name of the button. The following example disables the button instance myButton on the Timeline of the movie clip childClip, which is on the Timeline of the movie clip parentClip:

parentClip.childClip.myButton.enabled = false;

For a complete list of Button methods and properties, see Button (object) in the ActionScript Dictionary.