|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I have a need to be able to load legacy AS2 SWF's into a new AS3 project. I
know that this is not readily possible, because you can only communicate between the two via the LocalConnection class. So, what I have done is to create an AS2 proxy SWF. This SWF will handle the loading of all legacy SWF's and act as a middleman to pass the function calls between the pre-compiled SWF and the new SWF using the LocalConnection class. The new SWF also needs to be able to load AS3 SWF's, though. Because of this, I have the need to detect the AS version of the loaded SWF. If 1 or 2, then change the source to the AS2Proxy.swf, if 3 then simply load it. I have written the following code. My problem comes in when the init event fires. Regardless of the compiled version of the loaded SWF, it always traces 3 as the AS version. simulation.source = ModulePath+curPageXML.attribute("Path").toString() ; simulation.addEventListener(Event.INIT,doInitSim); function doInitSim(evt:Event):void { trace(simulation.loaderInfo.actionScriptVersion); // always traces 3 if(simulation.loaderInfo.actionScriptVersion > 2){ simulation.addEventListener(Event.COMPLETE,doVideo Ready); }else{ simulation.source = InterfacePath+"AS2Proxy.swf"; simulation.addEventListener(Event.COMPLETE,doProxy Ready); } } |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Alright, I solved this problem, only to come up with many more.
To solve this problem, I needed to point to the loaderInfo object of the UILoader's content. So: simulation.content.loaderInfo.actionScriptVersion. Now the proxy loads correctly, but I start getting errors immediately. Let me paste some code to show the next steps: First off. I immediately receive a StatusEvent error, though the path gets sent into the proxy and loads correctly. Next, when the complete event fires in the AS2 SWF - it sends a completion back up to let the AS3 SWF know that it finished (and any handling that needs to happen at that point.) I receive the following error: Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.LocalConnection was unable to invoke callback loadSwf. error=ReferenceError: Error #1069: Property loadSwf not found on com.applied.flash.events.AS2Connect and there is no default value. This is the AS2Proxy.swf code. var connection:LocalConnection = new LocalConnection(); connection.connect("AS3Connect"); if(path){ proxyLoader.contentPath = path; } connection.loadSwf = function( path:String ){ proxyLoader.contentPath = path; } proxyLoader.complete = function(){ connection.send("AS3Connect","swfLoaded",true); } function completion():Void { connection.send("AS3Connect","swfLoaded",true); } This is the AS2Connect class for hearing what is sent from the AS2 SWF package com.applied.flash.events { public class AS2Connect extends Object { public function swfLoaded( value:Boolean ):void { trace(value); } } } Finally, this is all of the related code in the AS3 swf var connection:LocalConnection = new LocalConnection(); var myIP:String = connection.domain; connection.client = new AS2Connect(); try{ connection.connect("AS3Connect"); }catch(e){ } simulation.source = ModulePath+curPageXML.attribute("Path").toString() ; contentPlayers.addChild(simulation); simulation.addEventListener(Event.INIT,doInitSim); function doInitSim(evt:Event):void { if(simulation.content.loaderInfo.actionScriptVersi on > 2){ simulation.addEventListener(Event.COMPLETE,doVideo Ready); }else if(simulation.source != InterfacePath+"AS2Proxy.swf"){ simulation.source = InterfacePath+"AS2Proxy.swf"; simulation.addEventListener(Event.COMPLETE,doProxy Ready); } } function doProxyReady(evt:Event):void { connection.send("AS3Connect","loadSwf", ModulePath+loadedXML.Pages.Page[tree.selectedIndex].attribute("Path").toString() ); connection.addEventListener(StatusEvent.STATUS,doS tatus); } function doStatus(evt:*){ trace(e); } |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
bump
|
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
bump
|
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Two bumps and no replies, so I have moved my query to the
http://www.adobe.com/cfusion/webforu...=665&threadid= 1377398&CFID=4594815&CFTOKEN=b9da2b8c7f8ac502-2BD544B7-0317-8A0D-9B9F409C1651D00 A&jsessionid=121220fe8f4b00efd56d2c42171a1ca6512 9 |
|
![]() |
| Outils de la discussion | |
|
|