Packageqnx.ui.buttons
Classpublic class LabelButton
InheritanceLabelButton Inheritance Button Inheritance SkinnableComponent Inheritance UIComponent Inheritance flash.display.MovieClip
Subclasses BackButton, CheckBox, RadioButton

The LabelButton class allows you to add a label to your button.

A label button.

View the examples

See also

Button
IconButton


Public Properties
 PropertyDefined By
 Inheritedcontainment : String
Gets or sets a property that determines how a component is contained within a parent container.
UIComponent
  embedFonts : Boolean
Gets or sets the embedFonts property of the internal TextField of the LabelButton.
LabelButton
  label : String
Gets or sets the label for the button.
LabelButton
 Inheritedselected : Boolean
Gets or sets the selected property of the button.
Button
 Inheritedsize : Number
Gets or sets the size for this component (as a percentage of the container's size, or in pixels).
UIComponent
 InheritedsizeMode : String
Gets or sets the size mode for this component.
UIComponent
 InheritedsizeUnit : String
Gets or sets the unit of measure for the size property.
UIComponent
 Inheritedtoggle : Boolean
Gets or sets the toggle property of the button.
Button
Public Methods
 MethodDefined By
  
Creates a new LabelButton instance.
LabelButton
 Inherited
destroy():void
Call this method when you want to have your object collected by the garbage collector.
UIComponent
 Inherited
drawNow():void
Calls the draw() method.
UIComponent
  
getTextFormatForState(state:String):TextFormat
Returns the TextFormat object for a specified state.
LabelButton
 Inherited
invalidate(property:String, invalidateNow:Boolean = false):void
Marks the property as invalid and the draw() method is called on the next frame or the next render, whichever comes first.
UIComponent
 Inherited
setPosition(x:Number, y:Number):void
Sets the x and y position of the component.
UIComponent
 Inherited
setSize(w:Number, h:Number):void
Sets the width and height of the component.
UIComponent
 Inherited
setSkin(cellSkin:Object):void
Set the skin object on the component for it to render.
SkinnableComponent
  
setTextFormatForState(format:TextFormat, state:String):void
Sets the TextFormat object for the label for a given state.
LabelButton
Protected Methods
 MethodDefined By
 Inherited
callLater(method:Function):void
Calls the specified method on the next frame or the next render, which ever happens first.
UIComponent
 Inherited
createInstance(linkage:Object):DisplayObject
Calling this method will attempt to create a DisplayObject instance based on the value of the linkage parameter.
UIComponent
 Inherited
draw():void
Called every time you set the width and height of the component.
UIComponent
 Inherited
isInvalid(property:String, ... properties):Boolean
Checks to see if the property is invalid and returns true if it is.
UIComponent
 Inherited
onAdded():void
Called when the instance is added to the stage.
UIComponent
 Inherited
onRemoved():void
Called when the instance is removed from the stage.
UIComponent
 Inherited
setEnabled(val:Boolean):void
Called when the enabled property changes.
UIComponent
 Inherited
validate(property:String):void
Lets the component know that the specified property has been validated.
UIComponent
Property Detail
embedFontsproperty
embedFonts:Boolean

Gets or sets the embedFonts property of the internal TextField of the LabelButton.

When set to false, fonts are rendered as device fonts. When set to true, you must specify a font using the font property of a TextFormat object and set it using the setTextFormatForState() method.

This font must be included in your application. If it is not included, the text will not be rendererd.

The default value is false.


Implementation
    public function get embedFonts():Boolean
    public function set embedFonts(value:Boolean):void

See also

labelproperty 
label:String

Gets or sets the label for the button.


Implementation
    public function get label():String
    public function set label(value:String):void
Constructor Detail
LabelButton()Constructor
public function LabelButton()

Creates a new LabelButton instance.

Method Detail
getTextFormatForState()method
public function getTextFormatForState(state:String):TextFormat

Returns the TextFormat object for a specified state.

Parameters

state:String — The state for the TextFormat object to return. Valid states are:
  • SkinStates.UP
  • SkinStates.DOWN
  • SkinStates.SELECTED
  • SkinStates.DISABLED

Returns
TextFormat — The TextFormat object for the specified state.

See also

setTextFormatForState()method 
public function setTextFormatForState(format:TextFormat, state:String):void

Sets the TextFormat object for the label for a given state. Valid states are:

Parameters

format:TextFormat — The TextFormat to set.
 
state:String — The state for which to change the TextFormat.

See also

Examples

The following code listing describes how to modify the appearance of your button text for a given state. You can set separate text format objects for each button state. This enables your button text to change color, position, size, or font face whenever a user clicks a button, when a button is disabled, etc.

In this short example, two text format objects are created and associated with button states. The text format object formatDown is created and associated with the button.down state using the setTextFormatForState method. The formatDown object specifies the button label text as white.

package
     {
         import flash.display.Sprite;
         import flash.text.TextFormat;
         import flash.text.TextFormatAlign;    
         import qnx.ui.buttons.LabelButton;
         import qnx.ui.skins.SkinStates;
         
         
         public class skinSample extends Sprite
         {
         
             public function skinSample()
             {
                 // create a text format for up, disabled, selected, etc. 
                 // black label text
                 var format:TextFormat = new TextFormat();
                 format.font = "BBAlpha Sans";
                 format.size = 16;
                 format.color = 0x000000;
                 format.align = TextFormatAlign.CENTER;
                 
                 // create a text format for the down state 
                 // white label text
                 var formatDown:TextFormat = new TextFormat();
                 formatDown.font = "BBAlpha Sans";
                 format.size = 16;
                 formatDown.color = 0xFFFFFF;
                 formatDown.align = TextFormatAlign.CENTER;
                 
                 var _button:LabelButton = new LabelButton();
                 
                 // set the formats for each state you want to address 
                 _button.setTextFormatForState(format,SkinStates.DISABLED);
                 _button.setTextFormatForState(format,SkinStates.UP); 
                 _button.setTextFormatForState(formatDown,SkinStates.DOWN);
                 _button.setTextFormatForState(format,SkinStates.SELECTED);
                 _button.setTextFormatForState(format,SkinStates.DISABLED_SELECTED);
                 
                 _button.label = "OK";
                 _button.x = _button.y = 175;
                 
                 addChild(_button);
             }
         }
     }