qnx.ui.buttons.IconButton

IconButton

Properties | Methods | Examples


Packageqnx.ui.buttons
Classpublic class IconButton
InheritanceIconButton Inheritance Button Inheritance SkinnableComponent Inheritance UIComponent Inheritance flash.display.MovieClip

The IconButton class enables you to place an image at the center of a button:

An icon button.



Class information:
PlayBook Tablet OS Version:   1.0.6

View the examples

See also

Button
LabelButton



Public Properties

 PropertyDefined By
 Inheritedcontainment : String
Gets or sets a property that determines how a component is contained within a parent container.
UIComponent
 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
  
Constructs an IconButton instance.
IconButton
 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
 Inherited
invalidate(property:String = all, 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
  
setIcon(image:Object):void
Sets the icon for the button.
IconButton
 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

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 = all):void
Lets the component know that the specified property has been validated.
UIComponent

Constructor Detail

IconButton()


public function IconButton()

Constructs an IconButton instance.

Method Detail

setIcon()


public function setIcon(image:Object):void

Sets the icon for the button. The icon is positioned in the center of the button.

The setIcon takes a path to an image (relative to your application file), a Bitmap instance, or a BitmapData instance. In the following example, a path to an image in the source project is passed into the setIcon method.

         myIconButton = new IconButton();
         myIconButton.setIcon("assets/icon.gif");
         

In the following example, an image is embedded in a class called Settings. The Settings object is instantiated as the argument for the setIcon() method.

         [Embed(source="assets/settings.png")] 
         public static var Settings:Class;
         
         myIconButton.setIcon( new Settings() );
         

Parameters

image:Object — The icon to be set. A String representing the URL to an external image, a Bitmap instance, or a BitmapData instance.

Examples

In the following example, a .gif is placed on an IconButton instance. The LocaleManager class's getCurrentLocale() method is called to reference an image in the resource folder of the current locale.

package
{
    import flash.display.Sprite;
    import flash.filesystem.File;
    
    import qnx.ui.buttons.IconButton;
    import qnx.ui.buttons.Button;
    import qnx.locale.LocaleManager;
    
    [SWF(height="600", width="1024", frameRate="30",
     backgroundColor="#FFFFFF")]
    public class buttontest extends Sprite
    {
        
        private var myIconButton:IconButton;
                
        public function buttontest()
        {
            initializeIconButton();
            
        }
                
        private function initializeIconButton():void
        {
            myIconButton = new IconButton();
            myIconButton.setIcon("locale/" + 
                LocaleManager.localeManager.getCurrentLocale() + 
                "/icon.gif");
            myIconButton.width = 100;
            myIconButton.setPosition(30, 30);
            
            this.addChild(myIconButton);
                
            
        }
    }
}