# XMLsocket onData problems

**URL:** <https://forum.kirupa.com/t/xmlsocket-ondata-problems/223336>\
**Category:** flash\
**Created:** [April 21, 2007, 12:16pm UTC](https://forum.kirupa.com/t/xmlsocket-ondata-problems/223336 "2007-04-21T12:16:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sirisian](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Sirisian](https://forum.kirupa.com/u/Sirisian)\
**Post date:** [April 21, 2007, 12:16pm UTC](https://forum.kirupa.com/t/xmlsocket-ondata-problems/223336/1 "2007-04-21T12:16:45Z")

</div>

I can’t seem to figure this out. I’ve read about the scoping problems. I’ve seen senocular’s tutorial even. However, I can’t seem to figure out what’s wrong with this implementation.  
\*Note: I don’t use XML, so I prototyped the onData to get rid of the XML parsing part.

If you could help me fix this I would be very grateful. I’ve been looking at it and testing it for like two days now.

```auto
class NetworkingManager {
    
    public var mySocket:XMLSocket;
    function NetworkingManager() {
        //variable to access this while inside an event
        var nmObj:NetworkingManager = this;
        this.mySocket = new XMLSocket();
        this.mySocket.connect("localhost", 3333);
        
        this.mySocket.onConnect = function(success) {
            if (success) {
                trace("Server connection established!");
            } else {
                trace("Server connection failed!");
            }
            nmObj.printData("HERE IN THE ON CONNECT")
        };
        
        this.mySocket.onClose = function() {
            trace("Server connection lost");
        };
    
        this.mySocket.prototype.onData = function(msg:String):Void {
            trace("DATA"+msg);
            nmObj.printData(msg);
        };
        
    }
    public function Ping():Void {
        mySocket.send("ping");
    }
    public function printData(msg:String):Void {
        trace("DATA: "+msg);
    }
}

```
