0 Replies Latest reply on Feb 8, 2007 1:00 AM by he4330937@yeah.net

    My application can not connect to FMS2

    he4330937@yeah.net
      My application can not connect to FMS2

      hi,all, Some things block me. Who can you help me? I appreciate your support.


      Server: FMS 2.0

      Client : Flash 8 ,Flex 2.0.1

      I find Flash 8 code is fine. It can connect to FMS2 with on error. I can find connect show in FMS console.

      But I find AS3 codes can not connect to FMS2. Why? I am very puzzle...:-(
      Error messages is nse.info.code:NetConnection.Connect.Failed nse.info.level:error...help me please..Thank you very much.

      My codes below.

      ==========Flash 8 code =========
      stop();
      // Open connection to FlashCom
      client_nc = new NetConnection();
      // Handle status message
      client_nc.onStatus = function(info) {
      trace("Level: " + info.level + newline + "Code: " + info.code);
      }
      client_nc.connect("rtmp://127.0.0.1/tutorial_text");
      // Initialize the typing stage
      TypingStage.text = "";
      // Create a remote shared object. client_nc.uri is the URI of the
      // NetConnection the shared object will use to connect to the
      // server. I.e., the one just created.
      text_so = SharedObject.getRemote("sharedtext", client_nc.uri, false);
      // The following is very important, nothing happens otherwise
      text_so.connect(client_nc);
      // Each time something changes in the shared object, the server
      // sends out a synchronization message. This onSync handler
      // updates the movie based on the information.
      text_so.onSync = function(list) {

      // Update the textArea in the typing stage with the latest
      // text from the shared object. The 'for' loop condition searches
      // through the list of changes, and the 'if' condition ensures
      // that we apply the relevant change only if someone other than
      // this client has changed the value.
      for ( var i = 0; i < list.length; i++ )
      if ( list.name == "textValue" && list.code != "success")
      {
      TypingStage.text = text_so.data.textValue;
      break;
      }
      };
      // Update the shared object every time the user types in new text
      TypingStage.onChanged = function()
      {
      text_so.data.textValue = TypingStage.text;
      };
      ===============Flex2 代码如下====================
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creati>
      <mx:Script>
      <![CDATA[
      import flash.net.*;
      import mx.controls.Alert;
      import flash.events.SyncEvent;

      private var client_nc:NetConnection;
      private var text_so:SharedObject;

      public function init():void
      {
      flash.system.Security.allowDomain(" http://127.0.0.1");

      rte.text = "";
      }

      public function ioEvent(ioe:IOErrorEvent):void
      {
      rte.text = rte.text+"/n"+" io:"+ioe.text;
      }

      public function connectStatus(nse:NetStatusEvent):void
      {
      //trace("Level: " + nse.info);
      rte.text = rte.text+"/n"+" nse.info.code:"+nse.info.code+" nse.info.level:"+nse.info.level;
      }

      public function click():void
      {
      client_nc = new NetConnection();
      client_nc.addEventListener(NetStatusEvent.NET_STATUS ,connectStatus);
      client_nc.addEventListener(IOErrorEvent.IO_ERROR,ioEvent);
      rte.text = "connect rtmp://127.0.0.1/tutorial_text ";
      client_nc.connect("rtmp://127.0.0.1/tutorial_text"); ///tutorial_text

      text_so = SharedObject.getRemote("sharedtext", client_nc.uri, false);
      text_so.addEventListener(SyncEvent.SYNC,syncShareObject);
      text_so.connect(client_nc);
      }

      public function syncShareObject(se:SyncEvent ):void
      {
      var list:Array = se.changeList;
      var i:int;
      for (i = 0; i < list.length; i++ ){
      if ( list.name == "textValue" && list.code != "success"){
      rte.text = text_so.data.textValue;
      break;
      }
      }
      }

      public function changeRTE():void
      {
      text_so.data.textValue = rte.text;
      }

      public function disconnect():void{
      if (client_nc.connected){
      client_nc.close();
      }
      }

      ]]>
      </mx:Script>
      <mx:RichTextEditor id="rte" x="23" y="19" width="626" height="337" cornerRadius="20" change="changeRTE()">
      </mx:RichTextEditor>
      <mx:Button x="105" y="381" label="Start Connection" width="204" click="click()"/>
      <mx:Button x="317" y="381" label="Disconnect" width="209" click="disconnect()"/>

      </mx:Application>