The following example creates a new Button instance and sets the button’s label to “Click me” using Flash and ActionScript 3.0.
Full code after the jump.
// ActionScript 3.0 import fl.controls.Button; var myButton:Button = new Button(); myButton.label = "Click me"; addChild(myButton);
The text displayed on a Button component instance can be changed by setting the instance’s label property. The label only accepts plain text (not HTML-formatted text) but text formatting can be applied by creating a text format and applying it to the button using the setStyle() method. For more information on working with button text formats, see “Setting text formats”.
If you are using an icon with a Button instance, you can control the placement of the text label, relative to the icon, by setting the labelPlacement property using one of the constants from the ButtonLabelPlacement class (fl.controls.ButtonLabelPlacement). For more information on working with button icons, see “Setting icons”.
Note: Setting a Button component’s label property dispatches a labelChange event (represented by the fl.events.ComponentEvent.LABEL_CHANGE constant).
For more information on the Flash/ActionScript 3.0 Button component, see the “Using the Button component” Flash Quick Start on Adobe.com.
{ 0 comments… add one now }