简体   繁体   English

flex 3嵌入图像,然后显示它们

[英]flex 3 embedding images and then displaying them

I have 2 images that are used hundreds of times throughout my application. 我有2张图片,在整个应用程序中使用了数百次。 Although they are only ~2.5 kilobytes each, they're multitude is causing the browser to load nearly 7 megs of data if reference them like this: 尽管它们每个只有约2.5 KB,但是如果引用这样的话,它们将导致浏览器加载近7兆的数据:

<mx:Image id="foo" source="images/addRed.png" ... />

Instead of having this issue, I would like to embed the image once, and then repeatedly reference the embedded object. 除了要解决此问题外,我想将图像嵌入一次,然后重复引用嵌入的对象。 I'm not exactly sure how to do this. 我不确定如何执行此操作。 From what I've read online, doing the following should work: 根据我在网上阅读的内容,应该执行以下操作:

<mx:Image id="foo" source="@Embed(source='images/addRed.png')" ... />

Is this the correct way to do it, or should I first embed it like this: 这是正确的方法吗?还是我应该先将其嵌入如下:

[Embed(source="images/minusRed.png")] public var minusRed:Class;

and then somehow call that reference from the ? 然后以某种方式从调用该引用?

Thanks in advance, Brds 预先感谢,Brds

After you embed it, do something like this: 嵌入后,请执行以下操作:

[Embed(source="images/minusRed.png")] 
public var minusRed:Class;

Reference it like this: 像这样引用它:

<mx:Image id="foo" source="{minusRed}" ... />

I believe that should work. 我相信应该可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM