PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Graphisme & Infographie > macromedia.flash > Loading an AS2 Swf into an AS3 project
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Loading an AS2 Swf into an AS3 project

Réponse
 
LinkBack Outils de la discussion
Vieux 24/06/2008, 14h32   #1
rritchey
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Loading an AS2 Swf into an AS3 project

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);
}
}

  Réponse avec citation
Vieux 24/06/2008, 15h21   #2
rritchey
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Loading an AS2 Swf into an AS3 project

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);
}

  Réponse avec citation
Vieux 10/07/2008, 15h12   #3
rritchey
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Loading an AS2 Swf into an AS3 project

bump
  Réponse avec citation
Vieux 14/07/2008, 14h34   #4
rritchey
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Loading an AS2 Swf into an AS3 project

bump
  Réponse avec citation
Vieux 16/07/2008, 13h32   #5
rritchey
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Loading an AS2 Swf into an AS3 project

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

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h19.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,16112 seconds with 13 queries