0 Replies Latest reply on Feb 18, 2010 4:12 AM by satheeshpallath12

    Error in chat code

    satheeshpallath12

      This is the code that i copied and pasted in my builder .It is showing some errors..This is the code that i saw in the video.It is the working code.Can anyone tell me what's the problem in the code...

       

      Code:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
          <mx:Script>
              <![CDATA[
                  import mx.messaging.channels.NetConnectionChannel;
                  private const sAddress:String = "rtmfp://stratus.adobe.com";
                  private const dKey:String = "Developer Key" ;
                  private var nc:NetConnection;
                  private var myPeerID:string;
                  private var farPeerID:String;
                 
                  private var sendStream:NetStream;
                  private var recvStream:NetStream;
                  private function initConnection():void
                  {
                      if(t1.text)
                      {
                          farpeerID = t1.text;
                      }
                      nc = new NetConnection;
                      nc.addEventListener(NetstatusEvent.NET_STATUS,ncStatus);
                      nc.connect(sAddress+dKey);
                     
                  }
                  private function ncStatus(event:NetStatusEvent):void
                  {
                      trace(event.info.code);
                      myPeerID = nc.nearID;
                      t1.text = myPeerID;
                  }
                 
                  private function initSendstream():void
                  {
                      trace("initSendstream");
                      sendStream = new Netstream(nc,NetStream.DIRECT_CONNECTIONS);
                      sendStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
                      sendstream.publish("media");
                     
                      var sendStreamClient:Object = new Object();
                      sendstreamClient.onPeerConnect = function(callerns:Netstream):Boolean
                      {
                          farPeerID = callerns.farID;
                          trace("onPeerConnect "+farPeerID);
                          return true;
                      }
                      sendStream.client = sendstreamClient;
                  }
                  private function initReceiveStream():void
                  {
                      recvStream = new NetStream(nc,farPeerID);
                      recvstream.addEventListener(NetStatus.NET_STATUS,netStatusHandler);
                      recvstream.play("media");
                      recvStream.client = this;
                  }
                  public function receiveSomeData(str:string):void
                  {
                      t3.text = str;
                  }
                  private function sendSomeData():void
                  {
                      sendStream.send("receiveSomeData",t2.text);
                  }
                  private function netStatusHandler(event:NetStatus):void
                  {
                      trace(event.info.code);
                     
                  }
                     
              ]]>
          </mx:Script>
          <mx:TextInput x="22" y="10" width="235" id="t1"/>
          <mx:Button x="265" y="10" label="Connect" click="initConnection"/>
          <mx:TextInput x="22" y="40" id="t2"/>
          <mx:Button x="190" y="40" label="send Data" click="sendSomeData()"/>
          <mx:TextInput x="22" y="70" id="t3" width="252"/>
          <mx:Button x="22" y="100" label="initSendStream" click="initSendstream()"/>
          <mx:Button x="174" y="100" label="initReceiveStream" click="initReceivestream();"/>
         
         
      </mx:Application>

       

       

       

      ERRORS:

      1046: Type was not found or was not a compile-time constant: NetStatus.    p2p/src    p2p.mxml    line 63    1266493948995    203

      1046: Type was not found or was not a compile-time constant: Netstream.    p2p/src    p2p.mxml    line 40    1266493948980    201

      1046: Type was not found or was not a compile-time constant: string.    p2p/src    p2p.mxml    line 55    1266493948980    202