0
votes

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.

1
Is your CustomBtn component based on a Flex 3 button (mx:Button) or a Flex 4 button (s:Button)? - Jason Towne

1 Answers

0
votes

Simply:

CustomBtn1.icon = pic2;