Skip to main content
Participating Frequently
January 2, 2011
Question

Passing data through connect().

  • January 2, 2011
  • 1 reply
  • 401 views

Hi, I found this example of a lobby in my flash media server book. But there's a little issue...

http://www.fusion-worx.be/other/fms/Lobby.JPG

          var nc:NetConnection;

          var rtmpNow:String;

          var userName:String;

          var users_so:SharedObject;

          var connectName:DataProvider;

          nc=new NetConnection();

          rtmpNow="rtmp://localhost/userlist/roomlist";

          nc.addEventListener (NetStatusEvent.NET_STATUS,checkConnect);

          button.addEventListener (MouseEvent.CLICK,addName);

          connectName=new DataProvider();

          function addName (e:MouseEvent)

          {

               nc.connect (rtmpNow,textInput.text);

          }

          function listPlace (e:SyncEvent)

          {

               list.dataProvider=connectName;

               list.removeAll ();

               for (var uName:String in users_so.data)

               {//no uName found.

                     if (users_so.data[uName] != null)

                     {

                          connectName.addItem ({label:users_so.data[uName]});

                     }

               }

          }

          private function checkConnect (e:NetStatusEvent)

          {

               if (e.info.code == "NetConnection.Connect.Success")

               {

                     button.label="Connected";

                     users_so=SharedObject.getRemote("users_so",nc.uri,false);

                     users_so.addEventListener (SyncEvent.SYNC,listPlace);

                     users_so.connect (nc);

               }

          }

When I press "connect", the name in textInput.text normally will be passed and added to the list under the button. But the list stays empty and textInput.text isn't passed. Does anyone know a solution?

Really thanks,

Thomas

    This topic has been closed for replies.

    1 reply

    Participating Frequently
    January 3, 2011

    Hi,

    The list is displayed empty because, you are populating the list with the value of the shared object's properties. Since you have not set any property in the code its displaying empty.

    Regards,

    Manish.