Current location: Oslo, Norway

Loading SWFs exported from Illustrator CS3 as MovieClips

Posted on Wednesday, April 09, 2008 @ 14:07 CET

Earlier Chris showed me an issue with Illustrator CS3 I hadn't come across. Basically exporting artwork to SWF for Flash Player 9 works fine, but (unexpectedly, at least for me) the resulting SWF is seen as a AVM1Movie when it gets loaded in to another SWF.

If this is an issue, then this AVM2Loader class should be able to help out. You use it just like the standard Loader class, and it hacks AVM1 movies to AVM2, though apparently there's an issue with audio). Sample code follows:

import net.fladdict.display.AVM2Loader;

var loader:AVM2Loader = new AVM2Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);
loader.load(new URLRequest("art.swf"));
addChild(loader);

function onLoaded(event:Event):void {
    var info:LoaderInfo = event.target as LoaderInfo;
    trace(info.content);
}

There is one little gotcha when exporting as a SWF in Illustrator. You have to use the "File > Save for Web & Devices" dialog. There you have to pick SWF as the format, Flash Player 9 as the output type and then either "AI File to SWF File" or "Layers to SWF Frames". Both work fine and trace out [object MovieClip] once loaded in.

What doesn't work for some reason is using "File > Export" and choosing SWF as the format and Flash Player 9 as the output type. Loading a SWF exported in this manner always traces out [object AVM1Movie]. Weird.

- paulo

Post a comment:

You must have Flash and JavaScript enabled to post a comment.