
Button.enabled Property
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
460
|
ActionScript Language Reference
Button.enabled Property
Boolean; allows or disallows button interaction
Flash 6
read/write
theButton.enabled
Description
The Boolean enabled property turns a button on (true) and off (false). It defaults to true.
When
enabled is false, theButton does not receive any user input; the hand cursor is not
shown, no events are triggered, and only the Up state is displayed. However, a disabled
button can still receive keyboard focus with the Tab key. To disable tab focus, set
theButton.tabEnabled to false.
Usage
The Tab key does not work reliably in Test Movie mode unless Control ➝ Disable
Keyboard Shortcuts is enabled. Be sure to test keyboard behavior in the Standalone Player,
if applicable, and in the Flash Player for all targeted web browsers.
Example
Buttons can be disabled in order to control a user’s interaction with an interface. For
example, a form’s Submit button can be disabled until all of the form’s input text fields
have been filled out by the user:
// Disable the Submit button at the outset
submit_btn.enabled = false;
submit_btn.tabEnabled = false;
// Add code that reenables the button when all fields have been filled out...
// For example:
mandatoryField.onChanged = function () {
if (this.text != "") {
submit_btn.enabled = true; ...