Flex Button icon load failed?

No Comments


The only thing why flex sucks is that components can’t actually load icons (Button class for example) i thought.

Yes, but that was until i found Ben Stucki‘s slight solution to this issue.
He wrote a nice utility class called IconUtility which creates BitmapAssets at run-time. This class is huge.
Sample button icon load up code:

var myBtn:Button = new Button();

myBtn.label = "press me";
myBtn.setStyle("icon", IconUtility.getClass(myBtn, "assets/my_icon.png"));

IconUtility Component for Dynamic Run-Time Icons

Download: IconUtility Class (302 kb)