| Package | qnx.ui.buttons |
| Class | public class LabelButton |
| Inheritance | LabelButton Button SkinnableComponent UIComponent flash.display.MovieClip |
| Subclasses | BackButton, CheckBox, RadioButton |
LabelButton class allows you to add a label to your button.
See also
| Property | Defined By | ||
|---|---|---|---|
![]() | containment : 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 | ||
![]() | selected : Boolean
Gets or sets the selected property of the button. | Button | |
![]() | size : Number
Gets or sets the size for this component (as a percentage of the
container's size, or in pixels). | UIComponent | |
![]() | sizeMode : String
Gets or sets the size mode for this component. | UIComponent | |
![]() | sizeUnit : String
Gets or sets the unit of measure for the size property. | UIComponent | |
![]() | toggle : Boolean
Gets or sets the toggle property of the button. | Button | |
| truncationMode : String
Gets or sets the truncationMode of the button. | LabelButton | ||
| Method | Defined By | ||
|---|---|---|---|
Creates a new LabelButton instance. | LabelButton | ||
![]() | destroy():void
Call this method when you want to have your object collected by the garbage collector. | UIComponent | |
![]() | drawNow():void
Calls the draw() method. | UIComponent | |
getTextFormatForState(state:String):TextFormat
Returns the TextFormat object for a specified state. | LabelButton | ||
![]() | 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 | |
![]() | setPosition(x:Number, y:Number):void
Sets the x and y position of the component. | UIComponent | |
![]() | setSize(w:Number, h:Number):void
Sets the width and height of the component. | UIComponent | |
![]() | 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 | ||
| embedFonts | property |
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.
public function get embedFonts():Boolean public function set embedFonts(value:Boolean):voidSee also
| label | property |
label:StringGets or sets the label for the button.
public function get label():String public function set label(value:String):void| truncationMode | property |
truncationMode:StringGets or sets the truncationMode of the button.
Valid values can be found in the TextTruncationMode class.
The default value is TextTruncationMode.TRUNCATE_TAIL.
public function get truncationMode():String public function set truncationMode(value:String):voidSee also
| LabelButton | () | Constructor |
public function LabelButton()
Creates a new LabelButton instance.
| 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:
|
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:
SkinStates.UPSkinStates.DOWNSkinStates.SELECTEDSkinStates.DISABLEDParameters
format:TextFormat — The TextFormat to set.
| |
state:String — The state for which to change the TextFormat.
|
See also
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);
}
}
}