使用数组嵌入许多图形
在 AS3 中,您可以将图形嵌入到类变量中:
[Embed(source="MenuAssets.swf", symbol="topSquare")]
public var TopMenuItem:Class;
我正在做的这个网站项目中有数百个资源,因此我想将资源嵌入到一个数组中以便快速访问。
我可以做这样的事情吗?它无法编译,所以我想知道它是否可能。
public var MenuAssets:Array = [
[Embed(source="MenuAssets.swf", symbol="topSquare")],
[Embed(source="MenuAssets.swf", symbol="botSquare")],
[Embed(source="MenuAssets.swf", symbol="leftSquare")],
[Embed(source="MenuAssets.swf", symbol="rightSquare")],
]
In AS3 you can embed a graphic into a Class variable:
[Embed(source="MenuAssets.swf", symbol="topSquare")]
public var TopMenuItem:Class;
I have hundreds of assets in this one website project I'm doing, so I want to embed assets into an array for quick access.
Can I do something like this? Its not compiling so I'm wondering whether its possible.
public var MenuAssets:Array = [
[Embed(source="MenuAssets.swf", symbol="topSquare")],
[Embed(source="MenuAssets.swf", symbol="botSquare")],
[Embed(source="MenuAssets.swf", symbol="leftSquare")],
[Embed(source="MenuAssets.swf", symbol="rightSquare")],
]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
恐怕你不能。您可以执行以下操作:
I'm afraid you can't. What you could do is the following:
您还可以将资产嵌入到单个 FLA 中。在 FLA 的库中,为每个类指定一个类名称,例如“graphics.menu.RightSquare”,然后将其导出为 SWC。配置 Flash Builder 项目以将 SWC 作为外部库加载。然后你可以做类似的事情:
You could also embed the assets in a single FLA. In the FLA's library, give each one a class name like "graphics.menu.RightSquare" then export it as a SWC. Configure your Flash Builder project to load the SWC as an external library. Then you can do something like:
一般来说,Flex 中的元数据标签适用于类级别变量。
但是您可以这样做:
In general, the metadata tags in Flex apply to a class level variable.
You can however do: