views:

1050

answers:

2

I'm building a shell application that will load other swf's inside of it based on which chapter and which section the user is in. The shell is written in actionscript 3 and it's loading various AS3, AS2 and AS1 swfs inside of it. I'm using LocalConnection after the AS2 and AS1 swf's have been loaded to set the correct variable for flash to find the right XML file to load for that chapter/swf. Thus far I've had no problems with loading AS2 swfs, but the 2 or 3 AS1 swfs I have just don't seem to set and load at all. I've done very little work with AS1 in the past other than debugging or configuring old code, so I'm wondering if I'm just missing something really obvious?

Here's the code to load and connect to the AS1 swf from AS3:

AS1SWF = evt.target.content;
sendSwf_lc = new LocalConnection();
addChild(AS1SWF);
stopPlayback(fileID);

private function stopPlayback(fileID:String):void {
sendSwf_lc.send("LocalConnection", "init", fileID, "English");
}

Here is the code in the AS1 application to receive that LocalConnection call.

var conn:LocalConnection;
conn = new LocalConnection();
conn.connect("LocalConnection");

conn.init = function(chapter, language) {

drillFile = "matching/xml/"+chapter+".xml";
drill = new XML();
drill.ignoreWhite = true;
drill.onload = getDrillXML;
drill.load(drillFile);
this.close();
}

function getDrillXML() {
trace("Application is starting now!");
//Rest of code
}

I've obviously left some things out, but this is where the swf gets to... It will load the AS1 swf correctly and send the correct variable and fire off the init function. It will not hit the getDrillXML function for the onLoad event. I've tested this with functioning XML and non-functioning XML, it will definitely throw an Error Loading message if the XML path is incorrect, so when I'm doing it correctly it's definitely loading the correct XML. I have a trace statement at the very top of the getDrillXML function and that never appears, so it has to be something involving the XML class in AS1 and it not properly loading the XML file, finishing the load and then moving on to the specified function after it's done.

I've tested this without the LocalConnection and just hard coding the variables in there with the local swf and it works just fine, everything loads up and the app works as intended.

Has anyone else ever run into this before? Is this a scope issue? Am I missing something from the AS1 version of LocalConnection or XML classes? The file is published to a flash player 6 swf.

Thanks for any help!

+1  A: 

sigh

I didn't write the code for the AS1 application and I don't know why this worked when the SWF is a stand alone application but why it doesn't work when it's loaded inside of an AS3 shell app, BUT the xml onLoad event is mis-spelled as onload in the original swf. I can't believe I wasted all this time on something so trivial haha, man... Sometimes coding can be depressing.

Thanks to anyone who read this, on to my next headache!

vanhornRF
don't you just love *not* getting compile-time errors for that ;)
grapefrukt
Yea the old AVM1 was really a pleasure and a treat to debug heh
vanhornRF
A: 

Uhm, could you confirm for me that this method works (when correctly spelled? :-). I want to do the same (Passing objects from an AS2 swf to an AS1 swf for Flash player 6/7 and higher respectively).

Also, if you would know any source that has information regarding refactoring AS1 code and symbols with a .fla file into decent OOP AS3 code then I would be ecstatic.

JurgenW