Justin Bachorik
Justin Bachorik

Reputation:

Actionscript - combining AS2 assets into a single SWF

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.

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.

I don't have access to Flex or mxmlc (and as the AS is timeline-based, they wouldn't necessarily help me). 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. 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)?

Upvotes: 0

Views: 1090

Answers (3)

Juan Pablo Califano
Juan Pablo Califano

Reputation: 12333

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.

Upvotes: 0

nikaji
nikaji

Reputation: 31

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.

If that doesn't work and if you're using MovieClip.loadMovie or MovieClipLoader.loadMovie you can overload their methods and intercept the 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://

Upvotes: 2

Rafe
Rafe

Reputation: 9275

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

Upvotes: -1

Related Questions