KoolMoves AS3 API Documentation | All Packages | All Classes | Index | Frames No Frames |
Class LabelButton

Package | km.components
Class | public class LabelButton
Inheritance | LabelButton BaseButton UIComponent 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
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined by
--- | --- | ---
|  | duotone : Array The duotone property can be used to convert the colors of the component into duotone. | UIComponent
|  | effectSpeed : int Speed in msec of the mouse over fade effect. | BaseButton
|  | enabled : Boolean Specifies if the component is enabled. If a component is disabled, it will be turned into grayscale and become partly transparent. | UIComponent
|  | height : 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
|  | minHeight : int Returns the minimum height of the button based on its scaling grid. | BaseButton
|  | minWidth : int Returns the minimum width of the button based on its scaling grid. | BaseButton
|  | on : Boolean Specifies the on/off state when the button is operating in hold or switch mode. | BaseButton
|  | onClick : Function onClick handler. | BaseButton
|  | operationMode : int Specifies the operation mode of the button. 0 = normal, 1 = hold, 2 = switch. | BaseButton
|  | origHeight : int Returns the original height of the button. | BaseButton
|  | origWidth : int Returns the original width of the button. | BaseButton
|  | smoothing : Boolean Sets the way the scaling grid is used. | BaseButton
|  | toolTip : String Text to use as toolTip when ToolTip is enabled. | UIComponent
|  | width : Number | UIComponent
|  | x : Number | UIComponent
|  | y : Number | UIComponent

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined by
--- | --- | ---
|  | LabelButton() | LabelButton
|  | 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
|  | 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
|  | setProperties(o:Object):void Sets a number of properties at once. | UIComponent
|  | setSize(w:int, h:int):void Sets the size width and height. | UIComponent
|  | setSkin(assetName:String, usePrefix:Boolean = true):void Sets the skin asset. | BaseButton
|  | setSound(mouseDownSound:Sound = null, mouseOverSound:Sound = null):void Sets the sounds of a button. | BaseButton

Events
Hide Inherited Events
Show Inherited Events

| Event | Summary | Defined by
--- | --- | --- | ---
|  | animationComplete | The animationComplete event is broadcasted when an animated move is completed. | UIComponent
|  | click | The click event is broadcasted when the button is clicked. It's also possible to use the onClick handler. | BaseButton

Property detail

label | property

`label:*` [read-only]

>> Reference to the button label.

Implementation
`public function get label():*`

labelBlendMode | property |

`labelBlendMode:String` [read-write]

Label blendMode.

Implementation
`public function get labelBlendMode():String`
`public function set labelBlendMode(value:String):void`

labelMarginH | property |

`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`

labelMarginV | property |

`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`)``

Last update : 04/05/2008