[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 Yahoo! Groups Sponsor ~-- Yahoo! Groups gets a make over. See the new email design. http://us.click.yahoo.com/XISQkA/lOaOAA/yQLSAA/nhFolB/TM ~- -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] * Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
RE: [flexcoders] Re: 1.5 - 2.0: Is it possible to use LocalConnection without creating ...
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 apps 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 Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to:[EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. __,_._,___
[flexcoders] Re: 1.5 - 2.0: Is it possible to use LocalConnection without creating ...
--- In flexcoders@yahoogroups.com, Tracy Spratt [EMAIL PROTECTED] wrote: Thanks, Peter. you're welcome Tracy, I've already learned some things from your posts here and there ;) regards, Peter Blazejewicz Yahoo! Groups Sponsor ~-- Check out the new improvements in Yahoo! Groups email. http://us.click.yahoo.com/6pRQfA/fOaOAA/yQLSAA/nhFolB/TM ~- -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] * Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/