Flex引用SWC文件中的Image

时间:2009-02-27 10:33:02

标签: flex flex3

如何在Flex中引用已包含在SWC文件中的图像?

1 个答案:

答案 0 :(得分:-1)

使用Embed元数据标记。类似的东西:

source="@Embed(source='relativeOrAbsolutePath')"

嵌入资源的语法为here

  

用于嵌入资源的语法取决于您在应用程序中嵌入资产的位置。 Flex支持以下语法:

* [Embed(parameter1, paramater2, ...)] metadata tag

  You use this syntax to embed an asset in an ActionScript file, or in an <mx:Script> block in an MXML file. For more information, see Using the [Embed] metadata tag.
* @Embed(parameter1, paramater2, ...) directive

  You use this syntax in an MXML tag definition to embed an asset. For more information, see Using the @Embed() directive in MXML.
* Embed(parameter1, paramater2, ...) directive

  You use this syntax in an <mx:Style> block in an MXML file to embed an asset. For more information, see Embedding assets in style sheets.

嵌入语法的所有三种变体都允许您访问相同的资源;唯一的区别是你在申请中使用它们的地方。

从文档中阅读有关加载资源的section。另外,Embedded Asset Classes