views:

1132

answers:

3

I am trying to load a swf written in AS2 into an AS3 swf - using Loader class and listening for Event.COMPLETE. in my onCompleteHandler function i want to add this to the stage so Im trying -

addChild(evt.currentTarget.content)

... but I get the following error message:

Error #2180: It is illegal to move AVM1 content (AS1 or AS2) to a different part of the displayList when it has been loaded into AVM2 (AS3) content.

The AS2 swwf has a lot of code and I really dont want to have to migrate to AS3 if I can avoid it. Anybody know if this is possible or know of a differnt way to add the loaded swf to the stage. How do I then go about calling functions in the loaded swf?

Here is a code snippet -

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
var request:URLRequest = new URLRequest("testLoadSwf.swf");
loader.load(request);

function onCompleteHandler(evt:Event) {
   addChild(evt.currentTarget.content);
}

Thanks all.

+1  A: 

The only really effective way to do this is by using LocalConnection. AS2 and AS3 can't communicate much with each other. If you still have access to the AS2 file's source, you can expose some functions with LocalConnection. There's also a neat helper class by Grant Skinner called SWFBridge that takes some of the groundwork out of doing this, it's available here: http://www.gskinner.com/blog/archives/2007/07/swfbridge_easie.html

nerdabilly
A: 

var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler); var request:URLRequest = new URLRequest("testLoadSwf.swf"); loader.load(request);

function onCompleteHandler(evt:Event) { //addChild(evt.currentTarget.content); } addChild(loader)

A: 

YESSSSS!!! that worked, even though the output still spits out the #2180 error. the as2 file loads into the as3 fp10 file.

thanks raghu!

geoff