package com.myorg.customComponents
{
import spark.components.Button;
import spark.primitives.BitmapImage;
public class IconButton extends Button
{
//--------------------------------------------------------------------------
//
// Constructor
//
//--------------------------------------------------------------------------
public function IconButton()
{
super();
}
//--------------------------------------------------------------------------
//
// Properties
//
//--------------------------------------------------------------------------
//----------------------------------
// icon
//----------------------------------
/**
* @private
* Internal storage for the icon property.
*/
private var _icon:Class;
[Bindable]
/**
*
*/
public function get icon():Class
{
return _icon;
}
/**
* @private
*/
public function set icon(val:Class):void
{
_icon = val;
if (iconElement != null)
iconElement.source = _icon;
}
//--------------------------------------------------------------------------
//
// Skin Parts
//
//--------------------------------------------------------------------------
[SkinPart(required="false")]
public var iconElement:BitmapImage;
//--------------------------------------------------------------------------
//
// Overridden methods
//
//--------------------------------------------------------------------------
/**
* @private
*/
override protected function partAdded(partName:String, instance:Object):void
{
super.partAdded(partName, instance);
if (icon !== null && instance == iconElement)
iconElement.source = icon;
}
}
}
//Can call the created icon in this way
ReplyDelete//EmbedIcons details
package com.myorg.utils
{
[Bindable]
public class EmbedIcons
{
//cursor asset for hdividedbox
[Embed(source="Assets.swf",symbol="mx.skins.cursor.HBoxDivider")]
public static var hDividerCursor:Class;
[Embed(source="assets/icons/diverThumbSkin.swf")]
public var diverThumbSkin:Class;
[Embed('assets/icons/minus.jpg')]
public static var rpAddIconId:Class;
}
}
Call Custom component IconButton with property icon="{EmbedIcons.repositoryRepositoryAdd}" along with it's class were the 2nd comment states the declaration of images on separate As file...
ReplyDeleteThis comment has been removed by the author.
ReplyDelete