0

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

4

1 回答 1

-1

Use the Embed metadata tag. Something like:

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

The syntax for embedding resources is given here:

The syntax that you use for embedding assets depends on where in your application you >embed the asset. Flex supports the following syntaxes:

* [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.

All three varieties of the embed syntax let you access the same assets; the only difference is where you use them in your application.

Read the section on loading resources from the documentation. Also, Embedded Asset Classes.

于 2009-02-27T11:17:25.283 回答