When using a Button component, you optionally can specify an icon that appears next to the button’s label. This allows you to easily add a check mark icon for a Submit button and a red X for a Cancel button, or you could put a product’s logo next to its name.

When working with icons, you’ll typically use the following styles:

  • icon – Name of the class to use as the icon when a toggle button is not selected and the mouse is not over the button.
  • disabledIcon – Name of the class to use as the icon when the button is disabled.
  • downIcon – Name of the class to use as the icon when the button is not selected and the mouse button is down.
  • overIcon – Name of the class to use as the icon when the button is not selected and the mouse is over the component.
  • upIcon – Name of the class to use as the icon when a toggle button is not selected and the mouse is not over the button.
  • selectedDisabledIcon – Name of the class to use as the icon when the button is selected and disabled.
  • selectedDownIcon – Name of the class to use as the icon when the button is selected and the mouse button is down.
  • selectedOverIcon – Name of the class to use as the icon when the button is selected and the mouse is over the component.
  • selectedUpIcon – Name of the class to use as the icon when the button is selected and the mouse button is up.

For more information on toggle buttons, see “Creating toggle buttons” Flash Quick Start on Adobe.com.

The following example demonstrates how to set a Button instance’s icon style. Note that only the icon style is set, and the icon propagates to the other icon styles automatically.

Full code after the jump.

Note: Setting a Button instance’s icon style sets the default icon for each of the button states (up, down, over, disabled, etc.)

// ActionScript 3.0
// Import the required component classes.
import fl.controls.Button;
 
/* Create a new Button component instance, set the icon style to the BulletCheck 
   linkage in the library, and add the button to the display list. */
var myButton:Button = new Button();
myButton.label = "Confirm";
myButton.move(10, 10);
myButton.setStyle("icon", BulletCheck);
addChild(myButton);

For more information on the Flash/ActionScript 3.0 Button component, see the “Using the Button component” Flash Quick Start on Adobe.com.

Tagged with:
 

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam Protection by WP-SpamFree