User Guide
136 Chapter 2: ActionScript Language Reference
Button.enabled
Availability
Flash Player 6.
Usage
my_btn.enabled:Boolean
Description
Property; a Boolean value that specifies whether a button is enabled. When a button is disabled
(the enabled property is set to
false), the button is visible but cannot be clicked. The default
value is
true. This property is useful if you want to disable part of your navigation; for example,
you may want to disable a button in the currently displayed page so that it can’t be clicked and the
page cannot be reloaded.
Example
The following example demonstrates how you can disable and enable buttons from being clicked.
Two buttons,
myBtn1_btn and myBtn2_btn, are on the Stage and the following ActionScript is
added so that the
myBtn2_btn button cannot be clicked:
// add two button instances on the Stage
// give them instance names of myBtn1_btn and myBtn2_btn
// place the following code on frame 1
// to enable or disable buttons
myBtn1_btn.enabled = true;
myBtn2_btn.enabled = false;
//button code
// the following function will not get called
// because myBtn2_btn.enabled was set to false
myBtn1_btn.onRelease = function() {
trace( "you clicked : " + this._name );
};
myBtn2_btn.onRelease = function() {
trace( "you clicked : " + this._name );
};