Button class

Inheritance UIObject > UIComponent > SimpleButton > Button

ActionScript Class Namespace mx.controls.Button

The properties of the Button class allow you to add an icon to a button, create a text label, or indicate whether the button acts as a push button, or a toggle switch at runtime.

Setting a property of the Button class with ActionScript overrides the parameter of the same name set in the Property inspector or Component Inspector panel.

The Button component uses the FocusManager to override the default Flash Player focus rectangle and draw a custom focus rectangle with rounded corners. For more information, see Creating custom focus navigation.

Each component class has a version property which is a class property. Class properties are only available on the class itself. The version property returns a string that indicates the version of the component. To access the version property, use the following code:

trace(mx.controls.Button.version);

Note: The following code returns undefined: trace(myButtonInstance.version);.

The Button component class is different from the ActionScript built-in Button object.

Method summary for the Button class

Inherits all methods from UIObject class and UIComponent class.

Property summary for the Button class

Method

Description

SimpleButton.emphasized

Indicates whether a button has the look of a default push button.

SimpleButton.emphasizedStyleDeclaration

The style declaration when the emphasized property is set to true.

Button.icon

Specifies an icon for a button instance.

Button.label

Specifies the text that appears within a button.

Button.labelPlacement

Specifies the orientation of the label text in relation to an icon.

Button.selected

When the toggle property is true, specifies whether the button is pressed (true) or not (false).

Button.toggle

Indicates whether the button behaves as a toggle switch.

Inherits all properties from UIObject class and UIComponent class.

Event summary for the Button class

Method

Description

Button.click

Broadcast when the mouse is pressed over a button instance or when the Spacebar is pressed.

Inherits all events from UIObject class and UIComponent class.