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/
 



Reply via email to