Actionscript - 将AS2资产组合到单个SWF中

时间:2021-05-21 23:32:54

I have a flash project that I'm trying to export as a single SWF. There's a main SWF file that loads about 6 other SWFs, and both the main and the child SWFs reference other external assets (images, sounds, etc). I'd like to package everything as a single .swf file so I don't have to tote the other assets around with the .swf.

我有一个flash项目,我试图导出为单个SWF。有一个主SWF文件可以加载大约6个其他SWF,主SWF和子SWF都引用其他外部资源(图像,声音等)。我想将所有内容打包为单个.swf文件,因此我不必使用.swf来包装其他资产。

All the coding is done in the timeline, but the assets haven't been imported into the Flash Authoring environment and I don't have time to do that right now (there are too many references to them everywhere). I'm hoping that there's just an option I'm missing that allows this sort of packaged export, but I haven't found anything like that.

所有编码都在时间轴中完成,但资产尚未导入Flash Authoring环境,我现在没有时间这样做(到处都有太多的引用)。我希望有一个我缺少的选项允许这种打包导出,但我还没有找到类似的东西。

I don't have access to Flex or mxmlc (and as the AS is timeline-based, they wouldn't necessarily help me). Any thoughts?

我无法访问Flex或mxmlc(因为AS是基于时间轴的,它们不一定能帮助我)。有什么想法吗?

Thanks!

PS...if there's no way of doing exactly what I'm saying, I could deal with having all the assets in a "assets" folder or something like that, so I'd just be toting around main.swf and an assets folder. The problem here is that all the references to the assets assume that they're in the same folder as the main.swf file, so everything's assumed to be local...is there a way to change the scope of all external references in Flash (so, for example, all local references in the code are actually searched in /assets)?

PS ...如果没有办法完全按照我所说的做,我可以处理所有资产都在“资产”文件夹或类似的东西,所以我只是在附近main.swf和资产夹。这里的问题是所有对资产的引用都假设它们与main.swf文件位于同一个文件夹中,所以假设所有内容都是本地的......有没有办法在Flash中更改所有外部引用的范围(例如,代码中的所有本地引用实际上是在/ assets中搜索的)?

3 个解决方案

#1


2  

You might be able to decompile your swfs into XML with swfmill/mtasc and use a fancy XSLT to recombine them and recompile with swfmill/mtasc.

您可以使用swfmill / mtasc将swfs反编译为XML,并使用花哨的XSLT重新组合它们并使用swfmill / mtasc重新编译。

If that doesn't work and if you're using MovieClip.loadMovie or MovieClipLoader.loadMovie you can overload their methods and intercept the url:

如果这不起作用,如果你使用的是MovieClip.loadMovie或MovieClipLoader.loadMovie,你可以重载他们的方法并拦截url:

var realLoadMovie:Function = MovieClip.prototype.loadMovie;

MovieClip.prototype.loadMovie = function(url:String, method:String) {
    return realLoadMovie("assets/" + url, method);
}

var test:MovieClip = createEmptyMovieClip("testclip", getNextHighestDepth());
test.loadMovie("test.swf");

You'll need to do some additional string parsing if the urls have a resource-type prefix such as file://

如果url具有资源类型前缀,例如file://,则需要进行一些额外的字符串解析

#2


0  

There's a base parameter you can add when you embed the swf, just like align, scale, etc. If base is set, all relative urls will be prefixed with whatever path you define (well, almost all; videos and file reference objects being the exception here). Other than that, I'd go with nikaji's solution.

你可以在嵌入swf时添加一个基本参数,就像对齐,缩放等一样。如果设置了base,所有相对url将以你定义的任何路径为前缀(好吧,几乎所有;视频和文件引用对象是例外)。除此之外,我会选择nikaji的解决方案。

#3


-1  

HI Justin,

It sounds like you need to look into using shared libraries. Check out:

听起来你需要考虑使用共享库。查看:

http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14767

#1


2  

You might be able to decompile your swfs into XML with swfmill/mtasc and use a fancy XSLT to recombine them and recompile with swfmill/mtasc.

您可以使用swfmill / mtasc将swfs反编译为XML,并使用花哨的XSLT重新组合它们并使用swfmill / mtasc重新编译。

If that doesn't work and if you're using MovieClip.loadMovie or MovieClipLoader.loadMovie you can overload their methods and intercept the url:

如果这不起作用,如果你使用的是MovieClip.loadMovie或MovieClipLoader.loadMovie,你可以重载他们的方法并拦截url:

var realLoadMovie:Function = MovieClip.prototype.loadMovie;

MovieClip.prototype.loadMovie = function(url:String, method:String) {
    return realLoadMovie("assets/" + url, method);
}

var test:MovieClip = createEmptyMovieClip("testclip", getNextHighestDepth());
test.loadMovie("test.swf");

You'll need to do some additional string parsing if the urls have a resource-type prefix such as file://

如果url具有资源类型前缀,例如file://,则需要进行一些额外的字符串解析

#2


0  

There's a base parameter you can add when you embed the swf, just like align, scale, etc. If base is set, all relative urls will be prefixed with whatever path you define (well, almost all; videos and file reference objects being the exception here). Other than that, I'd go with nikaji's solution.

你可以在嵌入swf时添加一个基本参数,就像对齐,缩放等一样。如果设置了base,所有相对url将以你定义的任何路径为前缀(好吧,几乎所有;视频和文件引用对象是例外)。除此之外,我会选择nikaji的解决方案。

#3


-1  

HI Justin,

It sounds like you need to look into using shared libraries. Check out:

听起来你需要考虑使用共享库。查看:

http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14767