Packagekm.components
Classpublic class LabelButton
InheritanceLabelButton Inheritance BaseButton Inheritance UIComponent Inheritance flash.display.Sprite

The LabelButton component class.


Example
import km.components.*;
import km.skins.*;

var tf:TextField;
var b1:LabelButton, b2:LabelButton, b3:LabelButton;
var b4:LabelButton, b5:LabelButton;

// Add a dynamic textfield.

tf = new TextField();
addChild(tf);

// Add a label button component.

b1 = new LabelButton();
ScriptedSkin.applyTo(b1);
b1.setSize(90,24);
b1.move(20,30);
addChild(b1);

// Clone the first button and add the clone.
// This way we don't have to skin all buttons separately.

b2 = b1.clone();
b2.y = 60;
addChild(b2);
 
// Do the same for button three, four and five.
 
b3 = b1.clone();
b3.y = 90;
addChild(b3);
 
b4 = b1.clone();
b4.move(220, 80, 3, 24, true); // animated move
addChild(b4);

b5 = b1.clone();
b5.move(220, 110, 2, 24, true); // animated move
addChild(b5);

// Set the labels for the buttons

b1.label.text = 'Button 1';
b2.label.text = 'Button 2';
b3.label.text = 'Button 3';
b4.label.text = 'Button 4';
b5.label.text = 'Button 5';
 
// First way of setting an action.
// KM supports nesting of anonymous functions so we can
// assign an anonymous function directly.
 
b1.onClick = function(){
 tf.text = 'Button 1 clicked';
}
 
// Second way of setting an action.
// We refer to a named function.

b2.onClick = b2Click;
 
// Third way of setting an action.
// We refer to a named function but do it this time by adding
// an event listener. The advantage is that multiple listeners
// can be added to one component.
 
b3.addEventListener('click', b3Click);
b4.addEventListener('click', b4and5Click);
b5.addEventListener('click', b4and5Click);


// Named function for button 2 click event.
// In case onClick is used, the Flash Player expects the function
// to have no parameters.

function b2Click():void {
 tf.text = 'Button 2 clicked';
}

// Named function for button 3 click event.
// In case addEventListener is used, the Flash Player expects the
// function to have one parameter.

function b3Click(e:Event):void {
 tf.text = 'Button 3 clicked';
}

// Named function for button 4 and 5 click event.
// The target property of the event that is passed to the function
// represents the button that broadcasted the event. We can use this
// to set one event function for multiple buttons.

function b4and5Click(e:Event):void {
 tf.text = e.target.label.text;
 tf.appendText(' clicked');
}



Public Properties
 PropertyDefined by
 Inheritedduotone : Array
The duotone property can be used to convert the colors of the component into duotone.
UIComponent
 InheritedeffectSpeed : int
Speed in msec of the mouse over fade effect.
BaseButton
 Inheritedenabled : Boolean
Specifies if the component is enabled.
If a component is disabled, it will be turned into grayscale and become partly transparent.
UIComponent
 Inheritedheight : Number
UIComponent
  label : *
[read-only] >> Reference to the button label.
LabelButton
  labelBlendMode : String
Label blendMode.
LabelButton
  labelMarginH : uint
Horizontal label margin.
LabelButton
  labelMarginV : uint
Vertical label margin.
LabelButton
 InheritedminHeight : int
Returns the minimum height of the button based on its scaling grid.
BaseButton
 InheritedminWidth : int
Returns the minimum width of the button based on its scaling grid.
BaseButton
 Inheritedon : Boolean
Specifies the on/off state when the button is operating in hold or switch mode.
BaseButton
 InheritedonClick : Function
onClick handler.
BaseButton
 InheritedoperationMode : int
Specifies the operation mode of the button.
0 = normal, 1 = hold, 2 = switch.
BaseButton
 InheritedorigHeight : int
Returns the original height of the button.
BaseButton
 InheritedorigWidth : int
Returns the original width of the button.
BaseButton
 Inheritedsmoothing : Boolean
Sets the way the scaling grid is used.
BaseButton
 InheritedtoolTip : String
Text to use as toolTip when ToolTip is enabled.
UIComponent
 Inheritedwidth : Number
UIComponent
 Inheritedx : Number
UIComponent
 Inheritedy : Number
UIComponent
Public Methods
 MethodDefined by
  
LabelButton
 Inherited
clone():*
Returns a clone of the component.
The skin of the component is cloned but other things like the text of a label or the items of a list aren't.
UIComponent
 Inherited
move(x:int, y:int, animationMode:int = 0, animationFrames:int = 12, easeInOut:Boolean = false):void
Moves the component to the specified coordinates.
UIComponent
  
setLabelTextColors(upColor:uint = 0, overColor:uint = 0, downColor:uint = 0):void
Set label text colors for the up, over and down states.
LabelButton
 Inherited
setProperties(o:Object):void
Sets a number of properties at once.
UIComponent
 Inherited
setSize(w:int, h:int):void
Sets the size width and height.
UIComponent
 Inherited
setSkin(assetName:String, usePrefix:Boolean = true):void
Sets the skin asset.
BaseButton
 Inherited
setSound(mouseDownSound:Sound = null, mouseOverSound:Sound = null):void
Sets the sounds of a button.
BaseButton
Events
 EventSummaryDefined by
 Inherited The animationComplete event is broadcasted when an animated move is completed.UIComponent
 Inherited The click event is broadcasted when the button is clicked.
It's also possible to use the onClick handler.
BaseButton
Property detail
labelproperty
label:*  [read-only]

>> Reference to the button label.

Implementation
    public function get label():*
labelBlendModeproperty 
labelBlendMode:String  [read-write]

Label blendMode.

Implementation
    public function get labelBlendMode():String
    public function set labelBlendMode(value:String):void
labelMarginHproperty 
labelMarginH:uint  [read-write]

Horizontal label margin.

The default value is 2.

Implementation
    public function get labelMarginH():uint
    public function set labelMarginH(value:uint):void
labelMarginVproperty 
labelMarginV:uint  [read-write]

Vertical label margin.

The default value is 2.

Implementation
    public function get labelMarginV():uint
    public function set labelMarginV(value:uint):void
Constructor detail
LabelButton()constructor
public function LabelButton()
Method detail
setLabelTextColors()method
public function setLabelTextColors(upColor:uint = 0, overColor:uint = 0, downColor:uint = 0):void

Set label text colors for the up, over and down states.

Parameters
upColor:uint (default = 0)
 
overColor:uint (default = 0)
 
downColor:uint (default = 0)