[Flex] Setting an icon on a Spark Button in Flex Hero
http://blog.flexexamples.com/2010/12/17/setting-an-icon-on-a-spark-button-in-flex-hero/
Spark Button icon 설정
1)
...
<fx:Script>
<![CDATA[
[Embed("assets/test.png")]
protected const ICON:Class;
]]>
</fx:Script>
...
<s:Button label="Spark Button with dynamic icon" icon="assets/test.png"/>
<s:Button label="Spark Button with inline embedded icon" icon="@Embed('assets/test.png')"/>
<s:Button label="Spark Button with metadata [Embed] icon" icon="{ICON}"/>
...
2)
...
<fx:Script>
<![CDATA[
[Embed("assets/test.png")]
protected const ICON:Class;
]]>
</fx:Script>
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
s|Button#btn1 {
icon:"assets/test.png";
}
s|Button#btn2 {
icon:Embed("assets/test.png");
}
s|Button#btn3 {
icocon:PropertyReference("ICON");
}
</fx:Style>
<s:Button label="Spark Button with dynamic icon:/>
<s:Button label="Spark Button with inline embedded icon"/>
<s:Button label="Spark Button with metadata [Embed] icon"/>
...
3)
...
<fx:Script>
<![CDATA[
[Embed("assets/test.png")]
protected const ICON:Class;
protected function init():void
{
btn1.setStyle("icon","assets/test.png");
btn2.setStyle("icon",ICON);
}
]]>
</fx:Script>
<s:Button label="Spark Button with dynamic icon:/>
<s:Button label="Spark Button with inline embedded icon"/>
<s:Button label="Spark Button with metadata [Embed] icon"/>
...