views:

452

answers:

3

Hi guys,

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)?

A: 

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

Rafe
aren't shared libraries external files from the main SWF? as in the opposite of combining everything into a single SWF?
davr
Yes, that's right. Shared libraries would not help here.
fenomas
+2  A: 

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://

nikaji
+1 I'm not sure if you need the return, though.
Juan Pablo Califano
A: 

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.

Juan Pablo Califano