Loading Legacy Flash 8 Content in a Flex 2.0.1 App
rewriting legacy content in as3 difficult business case make. but, if can load legacy swf (flash 8 swf) can make case of doing new content in as3 , keeping old content in as2. have been attempting do, i've run big snag.
i'm having trouble using localconnection flex project communicate flash8/as2 swf.
i wanted use localconnection pass strings , forth (as described jesse warden here: controlling flash player 8 swfs in flash player 9 swfs note: link appears down, may able recover google's cache).
when use code:
loadr= new swfloader();
loadr.height = 600;
loadr.width = 800;
loadr.y = 150;
loadr.x = 0;
loadr.source = "testingconnection.swf";
loadr.addeventlistener(event.complete,loadrcompleteevent);
i'm able load legacy (flash8) swf flex application. there no domain problems here.
but attempts @ using localconnection not paying off. error message (error #2082: connect failed because object connected).
here's code as3 side of connection (from flex):
import flash.net.localconnection;
public class as3toas2com
{
private var as3sendmessage:localconnection;
private var as2receivemessage:localconnection;
public function as3toas2com():void
{
as3sendmessage = new localconnection();
as2receivemessage = new localconnection();
as2receivemessage.connect("as2toas3con");
}
public function as2message(msg:string):void
{
trace("as2message: "+ msg);
sendas3message("test");
}
public function sendas3message(msg:string):void
{
as3sendmessage.send("legacyreceivecon","as3message",[msg]);
}
}
and here's code in as2 class use in flash cs3 fla:
class flashnineconnection
{
private var as2sendmessage:localconnection;
private var as3receivemessage:localconnection;
function flashnineconnection()
{
as3receivemessage = new localconnection();
as3receivemessage.connect("legacyreceivecon");
as2sendmessage = new localconnection();
}
function as3message(msg:string)
{
trace("flash 8/as2 receiving flex/as3");
trace(msg);
}
function sendas2msgtoas3(msg:string)
{
trace("flash8/as2 sending message flex/as3");
as2sendmessage.send("as2toas3con","as2message",[msg]);
}
}
here's code flash cs3 fla:
import flashnineconnection;
var ffcon:flashnineconnection = new flashnineconnection();
var timer:number;
timer = setinterval(getvalues,10);
function getvalues()
{
if (ffcon.messages != information_txt.text)
{
history_txt.text = history_txt.text + ffcon.messages;
information_txt.text = ffcon.messages;
}
}
ffcon.sendas2msgtoas3("as2 trying talk as3 movie");
send_btn.onrelease = function()
{
ffcon.sendas2msgtoas3("info: " + input_txt.text);
}
does have tips or advice?
william chadwick
disclaimer: of course code above not pretty (for example no try/catch blocks, etc)- conserve space took out lots of goodness.
background:
adobe's flex language reference on localconnection: http://livedocs.adobe.com/flex/201/langref/flash/net/localconnection.html
adobe as2 localconnection language reference: http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=lived ocs_parts&file=00002338.html
adobe has article here: http://kb.adobe.com/selfservice/viewcontent.do?externalid=749eaa47&sliceid=1
jesse warden here: controlling flash player 8 swfs in flash player 9 swfs
igor costa has fantastic example (very clear- though cannot read spanish comments - think it's spanish): http://www.igorcosta.org/?p=18
another excellent link one: http://groups.google.com/group/flex_india/msg/85ec872c7d94851a
this interesting: avm2 (as3) avm1 (as2/as1) communication via localconnection cannot">http://www.senocular.com/pub/kirupa/as3tips_p7.html[l=cannot load swfloader content in movieclip
i'm having trouble using localconnection flex project communicate flash8/as2 swf.
i wanted use localconnection pass strings , forth (as described jesse warden here: controlling flash player 8 swfs in flash player 9 swfs note: link appears down, may able recover google's cache).
when use code:
loadr= new swfloader();
loadr.height = 600;
loadr.width = 800;
loadr.y = 150;
loadr.x = 0;
loadr.source = "testingconnection.swf";
loadr.addeventlistener(event.complete,loadrcompleteevent);
i'm able load legacy (flash8) swf flex application. there no domain problems here.
but attempts @ using localconnection not paying off. error message (error #2082: connect failed because object connected).
here's code as3 side of connection (from flex):
import flash.net.localconnection;
public class as3toas2com
{
private var as3sendmessage:localconnection;
private var as2receivemessage:localconnection;
public function as3toas2com():void
{
as3sendmessage = new localconnection();
as2receivemessage = new localconnection();
as2receivemessage.connect("as2toas3con");
}
public function as2message(msg:string):void
{
trace("as2message: "+ msg);
sendas3message("test");
}
public function sendas3message(msg:string):void
{
as3sendmessage.send("legacyreceivecon","as3message",[msg]);
}
}
and here's code in as2 class use in flash cs3 fla:
class flashnineconnection
{
private var as2sendmessage:localconnection;
private var as3receivemessage:localconnection;
function flashnineconnection()
{
as3receivemessage = new localconnection();
as3receivemessage.connect("legacyreceivecon");
as2sendmessage = new localconnection();
}
function as3message(msg:string)
{
trace("flash 8/as2 receiving flex/as3");
trace(msg);
}
function sendas2msgtoas3(msg:string)
{
trace("flash8/as2 sending message flex/as3");
as2sendmessage.send("as2toas3con","as2message",[msg]);
}
}
here's code flash cs3 fla:
import flashnineconnection;
var ffcon:flashnineconnection = new flashnineconnection();
var timer:number;
timer = setinterval(getvalues,10);
function getvalues()
{
if (ffcon.messages != information_txt.text)
{
history_txt.text = history_txt.text + ffcon.messages;
information_txt.text = ffcon.messages;
}
}
ffcon.sendas2msgtoas3("as2 trying talk as3 movie");
send_btn.onrelease = function()
{
ffcon.sendas2msgtoas3("info: " + input_txt.text);
}
does have tips or advice?
william chadwick
disclaimer: of course code above not pretty (for example no try/catch blocks, etc)- conserve space took out lots of goodness.
background:
adobe's flex language reference on localconnection: http://livedocs.adobe.com/flex/201/langref/flash/net/localconnection.html
adobe as2 localconnection language reference: http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=lived ocs_parts&file=00002338.html
adobe has article here: http://kb.adobe.com/selfservice/viewcontent.do?externalid=749eaa47&sliceid=1
jesse warden here: controlling flash player 8 swfs in flash player 9 swfs
igor costa has fantastic example (very clear- though cannot read spanish comments - think it's spanish): http://www.igorcosta.org/?p=18
another excellent link one: http://groups.google.com/group/flex_india/msg/85ec872c7d94851a
this interesting: avm2 (as3) avm1 (as2/as1) communication via localconnection cannot">http://www.senocular.com/pub/kirupa/as3tips_p7.html[l=cannot load swfloader content in movieclip
you try blog entry made awhile back:
http://weblogs.macromedia.com/pent/archives/2006/07/using_actionscr.cfm
http://weblogs.macromedia.com/pent/archives/2006/07/using_actionscr.cfm
More discussions in Flex (Read Only)
adobe
Comments
Post a Comment