views:

370

answers:

3

I am converting a large application from AS2 to AS3. Part of the function is that it loads assets embedded in SWFs, which are old things. It is not possible to convert these to AS3 (there's really no code in them, it's just they're produced by tools that output flash 6 compatible SWFs).

The question is, how can I use this AVM1 (ActionScript VirtalMachine 1) graphical content inside an AVM2 application?

Here's what I used to do in AS2:

mcLoader = new MovieClipLoader();
mcLoader.addListener(this);
holder = createEmptyMovieClip('holder', 10);
mcLoader.loadClip("http://.../library.swf", holder);
function onLoadInit() {
  holder.attachMovie('GFXsymbolInsideLibraryswf', 'mysymbol', 123);
}

How can I do the same thing in AS3, loading the AS2 library swf? Am I going to need another layer of a 'wrapper' SWF that communicates via LocalConnection? Please tell me there's an easier way. Can I flip the bits on Library.swf to force it to load as an AVM2 SWF? Since there is no code inside it, maybe that would work?

A: 

You're probably best of by loading your legacy swf into an AVM1Movie object in AS3.

Luke
Thanks, any tips on how to load the symbols inside the AVM1Movie object?
davr
A: 

This looks like it may do what I want, I will update this answer later if I figure it out and nobody else replies.

EDIT: Nevermind. This doesn't work for what I want to do. I ended up having to use an intermediate wrapper SWF. I'm going to assume for now what I want is impossible to do. If anyone else has any suggestions, please leave an answer and I'll consider it.

davr
A: 

"Flipping" the bites is quite easy. I don't know if it will work, but you can give it a try. Since you have no code, you might actually have a chance...

Anyway, open up your swf with an hex editor. The version number is the fourth byte. You'll see something like this for a swf exported for FP 6:

43 57 53 06
This is the signature plus the version number. The first 3 bytes are the ascii string "CWS", which means the swf is compressed.

46 57 53 06 This is the signature for an uncompressed swf, "FWS".

Try changing 06 to 09 and see if it works...

Juan Pablo Califano
This is basically what 'ForcibleLoader' as mentioned below does. However it doesn't get around the fact that apparently in AVM1 swfs, movieclips are exported as 'symbols', whereas in AVM2 swfs, they are exported as actual 'classes'. So from within an AVM2 swf, there's no way to get the symbols out of the library of the AVM1 swf, if they aren't already attached to the stage.
davr
Makes sense, since you can export a swf for FP > 8 and AS 2.0 ...
Juan Pablo Califano