Apache flex 如何在flex中使用css文件作为图像源?

Apache flex 如何在flex中使用css文件作为图像源?,apache-flex,flex3,Apache Flex,Flex3,我有一个应用程序的图标,现在它嵌入了很多 脚本标签 在我的脚本标签中,我有 [Embed(source="/assets/icons/save_it_icon.png")] [Bindable] private var saveIcon:Class; 在我的flex组件中: <mx:Image id ="savePaneImg" source="{saveIcon}" buttonMode="true" toolTip

我有一个应用程序的图标,现在它嵌入了很多 脚本标签 在我的脚本标签中,我有

    [Embed(source="/assets/icons/save_it_icon.png")]

    [Bindable] 

    private var saveIcon:Class; 
在我的flex组件中:

<mx:Image  id ="savePaneImg" source="{saveIcon}" 
        buttonMode="true" 
        toolTip="Save comments" 
        click="doSave();" /> 

如何将此图像源移动到css文件中,以便在整个系统中恢复 不同的组件


提前感谢

源代码
不是样式属性,您不能在css中设置它。相反,我建议您创建一个类,在其中存储所有图像

[Bindable]
public class IconManager {

    [Embed(source="/assets/icons/save_it_icon.png")]
    public static var saveIcon:Class;

}
用法:

<mx:Image  id ="savePaneImg" source="{IconManager.saveIcon}" 
            buttonMode="true" 
            toolTip="Save comments" 
            click="doSave();" /> 

检查此代码,这将有助于您

public class IconSrc{
  [Embed(source="/assets/icons/save_it_icon.png")] 
  [Bindable]
  private var _icon1:Class
  public static function getSource(icon:String):Class{
    switch(icon){
     case "icon1": return _icon1;break;
      .
      .
      .
    }
  }
}

<mx:Image  id ="savePaneImg" source="{IconSrc.getSource('icon1')}"  
            buttonMode="true"  
            toolTip="Save comments"  
            click="doSave();" /> 
公共类ICONRC{
[嵌入(source=“/assets/icons/save_it_icon.png”)]
[可装订]
私有变量icon1:类
公共静态函数getSource(图标:字符串):类{
开关(图标){
案例“icon1”:返回icon1;中断;
.
.
.
}
}
}

我建议你查看这篇文章

创建一个类并将所有资产作为静态变量存储在其中。然后从各个地方访问它们。

+1对于绑定,但是您可以使用自定义元标记和CSS来管理资源,只是它必须在运行时使用反射,而且要复杂得多。