Hello,
I'm trying to do something that I think should be pretty basic.
I have a mx:Button that at runtime, I want to set the icon property to
artwork that I have embedded in a SWC file.
Now, I know about using the Embed tag declaring a new object of type Class,
like
[Embed(source="logo.gif")]
[Bindable] public var imgCls:Class;
However, I have artwork already declared in an imported SWC. I know the Embed
tag doesn't work for SWCs.
I use this artwork just fine in setting mx:Image.source for display all over
the application.
However, when I set the mx:Button.setTyle("icon", my_icon), I get an error:
TypeError: Error #1034: Type Coercion failed: cannot convert
my_i...@315b02e1 to mx.core.IFlexDisplayObject.
Heck, I even tried simple reflection using the following to create a Class that
resulted in the same error.:
var iconClass:Class = getDefinitionByName("my_icon") as Class;
btn.styleDeclaration.setStyle("icon", iconClass);
I've tried casting, creating classes, etc...but nothing works. I don't really
want to create another version of the artwork.
Any ideas on how to set the icon property of a Button at runtime with a symbol
declared in a SWC?