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


Comments:
Wow thx for that I had no idea how to get my project done with my CS4 artwork importing in as AVM1Movie instances! How is that not documented?
# March 23, 2009 02:52 CET
Hi Paulo
I have been struggling with exactly the same problem that you are describing all day. I was delighted when I found your post, but when using the AVM2Loader I still get the swfs (created by Illustrator CS3) loaded as AVM1.
I have used exactly the same code as in your example when trying this out but it still does not seem to work. Have tried toggling with settings in both Illustrator and Flash, without luck (as you describe I have used the 'Save for Web & Devices. dialog). Any ideas?
Regards, Jonas
# April 06, 2009 19:47 CET
Hi Jonas, that's strange I just tried it again with some local artwork following these steps and it worked.
I also checked using CS4 and now both the Export and "Save for Web and Devices" publish a SWF that works. If you have that lying around it might be worth checking out :)
# April 14, 2009 08:52 CET
Hi and thanks again Paolo
Really strange, I just can't get it right. I made a work-around for the problem so I can do without the solution this time. But I might bump into the problem again soon, plus it is always irritating not to solve things properly!
I ma not using CS4 yet.
# April 23, 2009 21:28 CET
Hi Paulo, thanks for this great post. It helped me a lot.
In comment #3 you wrote that the export in illustrator CS4 works fine for you.
I just installed a tryout and it still seems not to work for me.
I want to load a illustrator swf with movieClips that i can manipulate later in my main movie.
The following line does not work for me:
var info:LoaderInfo = event.target as LoaderInfo;
trace(MovieClip(info.content)); // Leads to type error with ai swf, works well with flash swf
Maybe you can help me?
Thanks in advance,
Robert
# May 07, 2009 22:45 CET
@Robert: what happens when you remove the MovieClip() cast? In other words, just trace(info.content).
If you still get AVM1Movie try using the Save for Web & Devices dialog like I mentioned above.
# May 15, 2009 14:23 CET
Has anyone come across a problem with the movie blinking while playing?
# May 21, 2009 20:46 CET
In CS4 this problem is even worse. I have tried every possible setting in the export and "save for web" dialogs. Illustrator ALWAYS outputs an swf file that traces as "AVM1Movie" when loaded in flash. The AVM2Loader class works, but not very good. At least it loads your file as a "MovieClip", and you can acess your symbol instances. But I don't like these kinds of workarounds. The main problem is illustrator. I think this is a serious bug in Adobe Illustrator. I have had a few cases about this in the Adobe Support Area, but without any success. The support folks just refers to the illustrator documentation, that says nothing about this problem. I have also tried submitting it as a bug report, but no response from Adobe yet.
If you too are having this problem, please help and submit it as a bug report here:
https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
I don't really think so, but mabye Adobe will listen if we scream loud enough...
# February 15, 2010 11:03 CET
Adobe confirms this problem still exists in CS5. Unbelievable...
# April 19, 2010 17:17 CET
Post a comment:
You must have Flash and JavaScript enabled to post a comment.