flex4 change custom btn icon
I followed the post here for Custom IconButton using flex4 link text However, I want to change the icon of the buttom at run time, so I create something like this in ActionScript :
[Bindable] [@Embed('assets/1.png')]
public var pic1:Class;
[Bindable] [@Embed('assets/2.png')]
public var pic2:Class;
public function clickToChange()
{CustomBtn1.setStyle("icon", pic2);}
and my .mxml is
<local:CustomBtn id="CustomBtn1" icon=开发者_如何转开发'{pic1}' width="80" height="80" click=clickToChange();/>
But I can't get CustomBtn change from pic1 to pic2 when click it. Any hint which part I did wrong? Thanks.
Simply:
CustomBtn1.icon = pic2;
精彩评论