--- In flexcoders@yahoogroups.com, "Theodore E Patrick" <[EMAIL PROTECTED]> wrote: Thanks for responding and putting me on the right track. I changed my code to add the Delegate as best I could but I still can't get it working:
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"> <mx:Script> <![CDATA[ import mx.utils.Delegate; public function serverConnected(success:Boolean) { if (success) { stat.text="Status = Connected"; } else { stat.text="Status = Error"; } } public function connect(event){ var socket:XMLSocket = new XMLSocket(); socket.onConnect = Delegate.create( this, serverConnected ); socket.connect(null, 9875); return } ]]> </mx:Script> <mx:Text text="XML Test App" width="205" textAlign="center" /> <mx:Button label="Connect to XML Server" click="connect()" /> <mx:Label id = "stat" text="Status = " width="144" textAlign="center" /> </mx:Application> > Chris, > > You need to use Delagate with XMLSocket callbacks. > > This should work: > > import mx.utils.Delegate; > > sock.onClose = Delegate.create( this, sockOnClose ); > > sock.onConnect = Delegate.create( this, sockOnConnect ); > > sock.onData = Delegate.create( this, sockOnData ); > > Cheers, > > Ted ;) > > > > > -----Original Message----- > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > > Behalf Of cshafer213 > > Sent: Thursday, July 07, 2005 2:12 PM > > To: flexcoders@yahoogroups.com > > Subject: [flexcoders] XML Socket Doesn't Work > > > > Can Anyone Tell Me what is wrong with the following code to connect to > > an XML socket server? The stat Lable should display either "status = > > Connected" or "status = Error" when the button is clicked, and nothing > > is happening. > > > > Thanks, > > > > Chris Shafer, George Weiss Associates > > > > <?xml version="1.0" encoding="utf-8"?> > > <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"> > > <mx:Script> > > <![CDATA[ > > > > public function serverConnected(success:Boolean) { > > if (success) { > > stat.text="Status = Connected"; > > } else { > > stat.text="Status = Error"; > > } > > } > > > > public function connect(event){ > > var socket:XMLSocket = new XMLSocket(); > > socket.onConnect=serverConnected; > > socket.connect(null, 9875); > > return > > } > > ]]> > > </mx:Script> > > <mx:Text text="XML Test App" width="205" textAlign="center" /> > > <mx:Button label="Connect to XML Server" click="connect()" /> > > <mx:Label id = "stat" text="Status = " width="144" textAlign="center" /> > > </mx:Application> > > > > > > > > > > -- > > 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 > > > > > > > > -- 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/