简体   繁体   English

动作脚本-将AS2资产合并到单个SWF中

[英]Actionscript - combining AS2 assets into a single SWF

I have a flash project that I'm trying to export as a single SWF. 我有一个Flash项目,尝试将其导出为单个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). 有一个主SWF文件,该文件可加载大约6个其他SWF,并且主SWF文件和子SWF文件都引用其他外部资源(图像,声音等)。 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. 我想将所有内容打包为单个.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). 所有编码都在时间轴中完成,但是资产尚未导入到Flash Authoring环境中,我现在没有时间这样做(到处都有对它们的引用太多)。 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. 我希望我只缺少一个选项,可以进行这种打包的导出,但是我还没有找到类似的东西。

I don't have access to Flex or mxmlc (and as the AS is timeline-based, they wouldn't necessarily help me). 我没有访问Flex或mxmlc的权限(并且由于AS是基于时间轴的,因此它们不一定会帮助我)。 Any thoughts? 有什么想法吗?

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. PS ...如果无法完全按照我的意思去做,我可以将所有资产都放在“资产”文件夹或类似的文件中,因此我只想在main.swf和资产周围夹。 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)? 这里的问题是,所有对资产的引用都假定它们与main.swf文件位于同一文件夹中,因此所有内容都假定是本地的...是否有办法更改Flash中所有外部引用的范围(因此,例如,实际上在/ assets中搜索代码中的所有本地引用)?

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://),则需要进行一些其他的字符串解析。

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). 嵌入swf时,您可以添加一个基本参数,就像align,scale等一样。如果设置了base,则所有相对url都会以您定义的路径作为前缀(好吧,几乎所有;视频和文件引用对象都是例外)。 Other than that, I'd go with nikaji's solution. 除此之外,我会选择nikaji的解决方案。

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 http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14767

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

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