如何嵌入大量的图片使用ActionScript 3 [英] How to embed a lot of images using Actionscript 3

查看:147
本文介绍了如何嵌入大量的图片使用ActionScript 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道什么是使用ActionScript嵌入大量图像更加实用的方法。首先,我不希望每次都从服务器上下载一个图像,然后,我想改变图像和/或他们的名字的数量。你有什么建议的这些要求?

i would like to know what is the more practical way to embed many images using actionscript. Firstly, i don't want to download an image every time from the server, and then, i would like to change the number of images and/or their names. What do you propose for these requirements?

PS:我已经惊动了嵌入标签,但似乎有点不方便在其使用,你必须声明一个新的类,每项资产,并分别实例化类

ps: I have been alerted for the Embed tag but it seems a little inconvenient in its use as you have to declare a new class for each asset and instantiate the class separately.

推荐答案

碰到上面的问题,我用的解决方案是一个有点简单,但是简单。你写一个批处理文件(.CMD)是经过一个目录下,生成AS3 code,那么它运行的编译器创建的.swf。

Met the problem above, the solution I use is a little straightforward, but simple. You write a batch file (.cmd) that goes through a directory, generating as3 code, then it runs the compiler to create .swf.

它看起来是这样的:

set target=a.as
@echo package { >%target%
@echo   import flash.display.Sprite; >>%target%
@echo   import flash.system.Security; >>%target%
@echo   public class %classname% extends Sprite{ >>%target%
@echo       Security.allowDomain('*'); >>%target%
for %%a in (*.png) do @echo         [Embed("%%~na.png")] public var %1_%%~na: Class; >>%target%
@echo       } >>%target%
@echo } >>%target%

这会产生类似:

it generates something like:

package { 
import flash.display.Sprite; 
import flash.system.Security; 
public class  extends Sprite{ 
Security.allowDomain('*'); 
        [Embed("a.png")] public var _beauty_nails: Class; 
        [Embed("b.png")] public var _club_dance: Class; 
        [Embed("c.png")] public var _club_date: Class; 
    } 
} 

这篇关于如何嵌入大量的图片使用ActionScript 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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