Hello everyone
I need to create a new CssStyleDeclaration for a button with only
icons specified; something like this
Code:
Button.iconButtonX{
upIcon: Embed(source="resources/images/icons/icon_up.png");
overIcon: Embed(source="resources/images/icons/icon_over.png");
downIcon: Embed(source="resources/images/icons/icon_down.png");
selectedUpIcon: Embed(source="resources/images/icons/icon_sel_up.png");
selectedOverIcon: Embed(source="resources/images/icons/icon_sel_over.png");
selectedDownIcon: Embed(source="resources/images/icons/icon_sel_down.png");
}
but instead of using Embed resources I need to load one (focus on only one , repeated for all) image path
is there any way to do that ?
I've already done this
Code:
public static function createNewIconStyle(path:String, styleName:String):void
{
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, _innerLoadComplete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, _innerError);
loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, _innerError);
loader.load(new URLRequest(path));
function _innerLoadComplete(e:Event):void
{
var ba:BitmapAsset = new BitmapAsset(Bitmap(e.target.content).bitmapData.clone(),"auto",true);
var bmpIcon:Class = getDefinitionByName(getQualifiedClassName(ba)) as Class;
var style:CSSStyleDeclaration = new CSSStyleDeclaration("."+styleName);
style.setStyle('upIcon', bmpIcon);
style.setStyle('overIcon', bmpIcon);
style.setStyle('downIcon', bmpIcon);
style.setStyle('selectedUpIcon', bmpIcon);
style.setStyle('selectedOverIcon', bmpIcon);
style.setStyle('selectedDownIcon', bmpIcon);
StyleManager.setStyleDeclaration("."+styleName, style, true);
}
function _innerError(e:Event):void
{
trace("NOT LOADED");
}
}
but ofcourse I get nothing and I know why ( I knew it was a long shot

)
thanks for any help