开发者

Actionscript add strings to embedded images?

Say I have something like this:

[Embed(source='../lib/ima开发者_StackOverflowges/image01.png')] var Image:Class

But I want to change that images based on another string like so:`

var StringData:String
StringData = "02";
[Embed(source='../lib/images/image'+ StringData +'.png')] var Image:Class

But this gives me an error, is there another way to do something like this?


Embedded resources are evaluated at compiling time so you can't set a dynamic path.

If you want a unique path by compile type (debug / release for exemple), you can use compiler variables :

[Embed(source=CONFIG::ICON_PATH)]
var Image:Class;

And add compiler args:

-define+=CONFIG::ICON_PATH,'../lib/images/image01.png'

or

-define+=CONFIG::ICON_PATH,'../lib/images/image02.png'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜