1 Reply Latest reply on Jun 2, 2006 6:11 AM by blemmo

    Problem with function

    srib
      Hi,

      I created a class file.
      ------------------------------------------------------------
      class sendInfo
      {

      public var _nc:NetConnection;
      public var pollSo:SharedObject;
      public function connectNc(rtmpString:String)
      {
      _nc = new NetConnection()
      _nc.onStatus = function(info)
      {
      trace(info.code)
      connectSo(_nc)
      }
      _nc.connect(rtmpString)
      }
      public function connectSo(nc)
      {

      trace("This connect SO function")
      pollSo = SharedObject.getRemote("poll_so", nc.uri, false)
      pollSo.connect(nc)

      }
      }
      ------------------------------------------------------------

      And this is the code in Fla file.

      -----------------------------------------------------------
      var sendInfoObj:sendInfo = new sendInfo()
      sendInfoObj.connectNc("rtmp:/poll")
      -----------------------------------------------------------

      i am trying to call connectSo(nc) function after the connection got is establshed.
      It is connecting to the server correctly and returning the string( "NetConnection.Connect.Success")
      Can any one tell me how to call the connectSo(nc) function.

      Thanks,
      Sridhar

        • 1. Re: Problem with function
          blemmo Level 1
          Hi,

          I'm not sure where the problem is. Is the connectSo(_nc) call inside the _nc.onStatus function not working? If so, it might be a scope issue. Try this:

          public function connectNc(rtmpString:String)
          {
          var that = this; // reference to the class object
          _nc = new NetConnection()
          _nc.onStatus = function(info)
          {
          trace(info.code)
          that.connectSo(this) // 'this' inside onStatus should reference to _nc
          }
          _nc.connect(rtmpString)
          }

          hth,
          blemmo