Create a button with an icon in actionscript

I want to create buttons with icons in Flex dynamically using Actionscript.

I tried this, with no success:

var closeButton = new Button();
closeButton.setStyle("icon", "@Embed(source='images/closeWindowUp.png");


I found an answer that works for me. In my .mxml file, I create Classes for the icons I will use:

// Classes for icons
public static var CloseWindowUp:Class;
public static var Down_Up:Class;
public static var Up_Up:Class;

In the Actionscript portion of my application, I use these classes when dynamically creating buttons:

var buttonHBox:HBox = new HBox();
var closeButton:Button = new Button();
var upButton:Button = new Button();
var downButton:Button = new Button();

closeButton.setStyle("icon", SimpleWLM.CloseWindowUp);

upButton.setStyle("icon", SimpleWLM.Up_Up);

downButton.setStyle("icon", SimpleWLM.Down_Up);

Need Your Help

python package installing for novices

python virtualenv pip packages nose

i'm learning python from on online book and have come to the stage where the author asks the reader to install pip, virtualenv, nose, and distribute. to make it fun, he asks the reader to figure ou...

rich:datatable rowspan issue

java jsf java-ee richfaces jstl

I need to create a rich:dataTable (or even extended) with the following features: