3 Replies Latest reply on Aug 18, 2010 6:24 PM by abeall

    NetStream.client can't be a class instance?

    abeall Level 3

      I tried this:

       

      netStream = new NetStream(netConnection, NetStream.DIRECT_CONNECTIONS);
      netStream.addEventListener(NetStatusEvent.NET_STATUS, streamStatus);
      netStream.publish("gamestate");
      netStream.client = this;
      
      ...
      
      public function onPeerConnect(ns:NetStream):Boolean {
           trace("onPeerConnect", ns.farID);
      }
      

       

      Inside a class called ClientStream. However I found that onPeerConnect was not being called. I changed .client to this:

       

      netStream.client = {
           onPeerConnect:function(ns:NetStream):Boolean {
                trace("onPeerConnect", ns.farID);
           }
      }
      

       

      And it works. Does this mean that you have to use a generic object like that for the client? Is there something I'm not understanding in the first example?