Thanks, Peter.

By working through your example, I was able to figure out what the difference between 1.5 and 2.0 was.

 

To state the difference again:

In Flex 1.5, in the receivieng local connection application, you could assign client methods directly to the Local Connection Object:

myLC.myMethod = [some function]

 

Apparently in 2.0 this class is “sealed” and you cannot do this.  Instead, you can subclass LocalConnection as the docs show, or, you can create a new object() directly in the app’s AS code, add the methods to that object, then assign the object to the LocalConnection.client property.

 

The sending LC does not need to change.

 

Thanks for your excellent example.

 

Tracy


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Peter Blazejewicz
Sent: Thursday, June 15, 2006 8:02 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: 1.5 -> 2.0: Is it possible to use LocalConnection without creating ...

 

Hello Tracy,

When writing my custom trace target based on LC I found that
subclassing LC worked best for me,
however except of using 2 methods described in docs (subclass,
dynamic class) you can simply put any object to "client" property at
runtime, even created ad-hoc:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="100%
" height="100%"
creationComplete="initApp()">
<mx:Script>
<![CDATA[
private var lc:LocalConnection;
private function initApp():void{
lc = new LocalConnection();
var lcName:String = "__test__";
var success:Boolean = false;
try{
lc.connect(lcName);
lc.client = getClient();
success = true;
}catch(e:Error){
out.text += "already connected"+"\n";
}
if(success){
out.text += "successfully connected"+"\n
";
var sendingLC:LocalConnection = new
LocalConnection();
sendingLC.addEventListener(StatusEvent.
STATUS, function(e:StatusEvent):void{
out.text += "sending event: "+e.
level+"\n";
});
sendingLC.send(lcName, "doMessage", "
Hello World!");
sendingLC.send(lcName, "doClose");
// after close we should get "error"
status code
sendingLC.send(lcName, "doMessage", "
test");
}
}
private function getClient():Object{
var c:Object = new Object();
c.doMessage = function(msg:String):void{
out.text += "msg received: "+msg+"\n";
}
c.doClose = function():void{
lc.close();
out.text += "connection closed"+"\n
";
}
return c;
}
]]>
</mx:Script>
<mx:TextArea id="out" width="100%" height="100%"/>
</mx:Application>

kind regards,
Peter Blazejewicz

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to