如何以正确的方式在 Actionscript 3/Flex 3 中嵌入图像? [英] Howto embed images in Actionscript 3 / Flex 3 the right way?

查看:24
本文介绍了如何以正确的方式在 Actionscript 3/Flex 3 中嵌入图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个游戏,其中在 Actionscript/Flex 3 (Flash) 中使用了大量图像.现在我已经到了设计师阶段,我必须找出一种使用嵌入图像的结构方式(必须通过旋转、颜色等进行操作).

I'm creating a game where a lot of images are being used in Actionscript / Flex 3 (Flash). Now that I've reached the designer stage, I have to work out a structural way of using embedded images (which have to be manipulated with rotation, color, etc.).

不幸的是,经过一番调查后,您似乎必须手动嵌入图像才能使用它们.我目前的设置如下:

Unfortunately, after investigating a bit, it looks like you have to manually embed images before you can use them. I currently have it setup like this:

Resource.as 类文件:

Resource.as class file:

package
{
    public final class Resource
    {
        [Embed (source="/assets/ships/1.gif" )]
        public static const SHIPS_1:Class;
    }
}

所以,对于一艘船,我不得不这样做:

So, just for one ship I so for have to:

将图片放入正确名称的正确文件夹中在 Resource.as 文件中以同样的方式命名在 Resource.as 文件中创建同名常量

Put the image in the correct folder with the correct name Name it in the same way in the Resource.as file Create the constant with the same name in the Resource.as file

尽管只需将文件放在指定的文件夹中即可.

Even though this should all be possible by simply putting the file in a specified folder.

更糟糕的是,我仍然必须使用:

To make things even worse, I still have to call it using:

var test:Bitmap = new Resource.SHIPS_1();

在创建非常庞大的应用程序时,一定有更好的方法来处理资源吗?想象一下,我需要成千上万张图片,这个系统根本装不下.

There must be better ways to handle resources when creating very huge applications? Imagine I need thousands of images, this system simply wouldn't fit.

推荐答案

代替

var test:Bitmap = new Resource.SHIPS_1();

使用

myImage.source = Resource.SHIPS_1;

嵌入是正确的.:D 你使用它的方式是错误的 :)

The embedding is correct. :D the way you use it is wrong :)

阿德里安

这篇关于如何以正确的方式在 Actionscript 3/Flex 3 中嵌入图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆