我找到了一个适合我的答案.在我的.mxml文件中,我将为我将使用的图标创建类:
// Classes for icons [Embed(source='images/closeWindowUp.png')] public static var CloseWindowUp:Class; [Embed(source='/images/Down_Up.png')] public static var Down_Up:Class; [Embed(source='/images/Up_Up.png')] public static var Up_Up:Class;
在我的应用程序的Actionscript部分中,我在动态创建按钮时使用这些类:
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); buttonHBox.addChild(closeButton); upButton.setStyle("icon", SimpleWLM.Up_Up); buttonHBox.addChild(upButton); downButton.setStyle("icon", SimpleWLM.Down_Up); buttonHBox.addChild(downButton);