Methods | Properties | Effects | Events | Styles | Examples Frames | No Frames

mx.controls
Class Button

Inheritance ImageInheritance ImageInheritance Image
Direct Known Subclasses
           mx.containers.accordionclasses.AccordionHeader, mx.controls.CheckBox, mx.controls.Link, mx.controls.RadioButton

class Button
extends mx.controls.SimpleButton

The Button control is a commonly used rectangular button. Button controls look like they can be pressed. They can have a text label, an icon, or both on their face. Button controls typically perform an action when clicked. However, toggle-style Button controls stay pressed when clicked and act like a radio button. When a user clicks a Button control, it broadcasts a click event. You can customize the look of a Button control and change its functionality from push to toggle.

The Button control extends the SimpleButton class. It adds a label and text with layout, and the ability to resize without distorting the skin.

Note: The Button control does not respond to the valueChanged event, even though it is defined in the UIComponent class. You cannot set the skinning properties inherited from the SimpleButton control in MXML.

MXML Syntax

The <mx:Button> tag inherits all the properties of its parent classes, and the following properties:

 <mx:Button
icon="No default."
label="No default."
labelPlacement="right|left|bottom|top"
repeatInterval="35"
repeatDelay="500"
selected="false|true"
toggle="false|true"
click="Event handler; no default."
/>

Click here to view the Examples

Methods

Methods inherited from class mx.core.UIComponent
drawFocus   getFocus   getFocusManager   setEnabled   setFocus  

Methods inherited from class mx.core.UIObject
addEventListener   applyProperties   buildDepthTable   commitProperties   constructObject2   createAccessibilityImplementation   createChildAtDepth   createChildren   createClassChildAtDepth   createClassObject   createEmptyObject   destroyObject   dispatchEvent   doLater   draw   drawRect   executeBindings   fillRect   findNextAvailableDepth   getRepeaterItem   getStyle   handleEvent   init   invalidate   invalidateLayout   invalidateProperties   invalidateSize   invalidateStyle   layoutChildren   measure   move   redraw   removeEventListener   setDepthAbove   setDepthBelow   setMask   setSize   setSizeNoLayout   setStyle   swapDepths  



Properties
       icon: String
Symbol name of the icon to appear on this Button.
       label: String
Text to appear on the Button.
       labelPlacement: String
Orientation of the label in relation to a specified icon.
staticversion: String
Version string for this class.

Properties inherited from class mx.controls.SimpleButton
falseDisabledSkin   falseDownSkin   falseOverSkin   falseUpSkin   selected   toggle   trueDisabledSkin   trueDownSkin   trueOverSkin   trueUpSkin   version  

Properties inherited from class mx.core.UIComponent
enabled   errorString   tabEnabled   tabIndex   version  

Properties inherited from class mx.core.UIObject
alpha   baselinePosition   className   depth   documentDescriptor   height   heightFlex   id   instanceIndices   isDocument   kStretch   layoutHeight   layoutWidth   maxHeight   maxWidth   minHeight   minWidth   mouseX   mouseY   nestLevel   oldHeight   oldWidth   oldX   oldY   parent   parentApplication   parentDocument   percentHeight   percentWidth   preferredHeight   preferredWidth   repeaterIndices   scaleX   scaleY   styleName   tabEnabled   toolTip   version   visible   width   widthFlex   x   y  



Effects

Effects inherited from class mx.core.UIComponent
focusInEffect   focusOutEffect  

Effects inherited from class mx.core.UIObject
creationCompleteEffect   hideEffect   mouseDownEffect   mouseOutEffect   mouseOverEffect   mouseUpEffect   moveEffect   resizeEffect   showEffect  



Events
clickBroadcast when the user clicks on the button. The target property of the event object contains a reference to the component that triggered the event. The type property contains the name of the event, click.

Events inherited from class: mx.controls.SimpleButton
buttonDown  buttonDragOut  click 

Events inherited from class: mx.core.UIComponent
focusIn  focusOut  invalid  keyDown  keyUp  valid  valueCommitted 

Events inherited from class: mx.core.UIObject
creationComplete  dragComplete  dragDrop  dragEnter  dragExit  dragOver  draw  effectEnd  effectStart  hide  hideToolTip  initialize  load  mouseChangeSomewhere  mouseDown  mouseDownSomewhere  mouseMove  mouseMoveSomewhere  mouseOut  mouseOver  mouseUp  mouseUpSomewhere  move  resize  show  showToolTip  unload 



Styles
borderThickness Type: Number   CSS Inheritance: no
Thickness of button border "ring". A value of 0 means no border. Any value greater than 2 creates a glowing "ring" around the button. The default value is 3.
cornerRadius Type: Number   CSS Inheritance: no
Radius of button corners. The default value is 5.
horizontalGap Type: Number   CSS Inheritance: no
Gap between the buttons label and icon, when labelPlacement = "left" or "right". The default value is 2.
textRollOverColor Type: Number   Format: Color   CSS Inheritance: yes
Text color of the label as you move the mouse pointer over the button. The default value is 0x2B333C.
textSelectedColor Type: Number   Format: Color   CSS Inheritance: yes
Text color of the label as you press it. The default value is 0x000000.
verticalGap Type: Number   CSS Inheritance: no
Gap between the buttons label and icon, when labelPlacement = "top" or "bottom". The default value is 2.

Styles inherited from class mx.controls.SimpleButton
repeatDelay   repeatInterval  

Styles inherited from class mx.core.UIComponent
backgroundAlpha   backgroundColor   backgroundDisabledColor   backgroundImage   backgroundSize   barColor   borderCapColor   borderColor   borderSides   borderStyle   borderThickness   cornerRadius   disabledColor   dropShadow   errorColor   fillColors   highlightColor   modalTransparency   scrollTrackColor   selectedFillColors   shadowCapColor   shadowColor   shadowDirection   shadowDistance   symbolBackgroundColor   symbolBackgroundDisabledColor   symbolBackgroundPressedColor   symbolColor   symbolDisabledColor   themeColor  

Styles inherited from class mx.core.UIObject
color   fontFamily   fontSize   fontStyle   fontWeight   horizontalGap   leading   marginLeft   marginRight   textAlign   textDecoration   textIndent   verticalGap  



Property Detail

icon

icon: String  

Symbol name of the icon to appear on this Button. The default value is undefined, meaning that no icon should appear.

The icon must be embedded at compile time as a symbol in the SWF file, as opposed to being downloaded as an image from the server at runtime. To embed the icon in the SWF file, use the @Embed MXML compiler directive:
icon="@Embed('relativeOrAbsoluteURL')"
The URL can be for a JPEG, GIF, PNG, SVG, or SWF image on the server. The MXML compiler embeds the image as a symbol and replaces the @Embed directive with the symbol name it generated.

The relative placement of the button's label and icon is determined by the labelPlacement property.


label

label: String  

Text to appear on the Button. The default value is an empty string.


labelPlacement

labelPlacement: String  

Orientation of the label in relation to a specified icon. Possible values are right, left, bottom, and top. The default is right.


version

static  version: String  

Version string for this class.


Examples
ButtonExample.mxml
<?xml version="1.0"?>
<!-- Simple example to demonstrate the Button control -->
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" backgroundColor="#FFFFFF"
    height="100%" width="100%">

    <mx:Script>
        <![CDATA[
        
        function printMessage(event)
        {
          message.text += newline + event.target.label + " pressed";
        }
      
      ]]>
    </mx:Script>

    <mx:Panel title="Button Panel" height="100%" width="100%">

        <!-- The button can contain an image, as in the "Button with Icon" button -->
        <mx:Button id="iconButton" icon="@Embed('FlexLogo.gif')" label="Button with Icon"
            labelPlacement="right" color="#993300" click="printMessage(event)"/>
    
        <!-- The size of the button and the label attributes can be customized -->
        <mx:Button label="Customized Button" color="#993300" toggle="true" selected="true"
            textAlign="left" fontStyle="italic" fontSize="13" width="{iconButton.width}" click="printMessage(event)"/>

        <!-- By default, the look and feel of the customized button is similar to the Default Button.  -->
        <mx:Button label="Default Button" click="printMessage(event)"/>

        <mx:TextArea id="message" text="" editable="false" height="100%" width="100%"
            color="#0000FF"/>

    </mx:Panel>

</mx:Application>




 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flex/15/asdocs_en/mx/controls/Button.html