1

我有很多应用程序图标,现在它嵌入在脚本标签中,例如:在我的脚本标签中

    [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 文件以在不同组件之间重用?

提前致谢

4

3 回答 3

2

source不是样式属性,不能在 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();" /> 
于 2012-04-18T09:00:41.630 回答
0

检查此代码,这将对您有所帮助....

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();" /> 
于 2012-04-18T14:54:19.523 回答
0

我建议您查看这篇文章 如何以正确的方式在 Actionscript 3 / Flex 3 中嵌入图像?

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

于 2012-04-18T15:01:02.263 回答