2 Replies Latest reply on Apr 12, 2010 8:37 AM by dakasadakasadaka

    works in flash but not in flex 4 or flex 3 sharedobjects


      In the flash the codes work fine and if I translate to flex it doesn't give me real chat application....

      If I start two of those swf's. I'm starting to chat and on the that swf it gives the text properly in the <s:TextArea>

      like this

      hello test

      hello testing app

      hello test

      hoi test

      hallo test


      but on all other swf that started on the same time it gives only the last text that I typed in....not the text before!

      Only the last one like:

      hallo test

      The both swf are connected to fms at the same time, but the other doesn't save the last text.


      So on the flash in as3.0 there is private var textArea:TextArea; and at end of the codes is textAreaChat.appendText (textInput.text + "\n");

      the same I have doen in flex 4 as you can see bellow, but it doesn't work!


      So what can it be??

      tnx. daka


      hier are the codes from my flex application:


      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
          minWidth="1024" minHeight="768"


          <!-- Messaging Declarations -->


          <!-- UI Declarations -->


          <s:Panel title="Simple Flex Chat">
              <s:TextArea id="textAreaChat"
      width="385" height="220" horizontalCenter="0"
              <s:TextInput id="textInput" width="385"  />
              <mx:ControlBar horizontalAlign="center" width="385">
                  <s:Button id="button" label="Send" click="sendMsg(event)" />


          <!-- Event-Handling Script -->


                import flash.display.Sprite;
                import flash.events.Event;
                import flash.events.KeyboardEvent;
                import flash.events.SyncEvent;
                import flash.events.NetStatusEvent;
                import flash.events.MouseEvent;
                import flash.net.SharedObject;
                import flash.net.NetConnection;
                import flash.text.TextField;
                import flash.text.TextFieldAutoSize;


                private var outputText:TextField;
              //private var button:Button;
              private var text_so:SharedObject;
              private var nc:NetConnection;
              //private var textArea:TextArea;
              //private var textInput:TextInput;
              private var rtmpGo:String;
              private var good:Boolean;
              private var noName:Boolean;


              public function TextSO ():void
                  /* //Set up UIs
                   textArea=new TextArea();
                   textArea.setSize (200,300);
                   textArea.move (20,20);
                   addChild (textArea);


                   textInput=new TextInput();
                   textInput.move (20,330);
                   addChild (textInput);


                   button=new Button();
                   button.move (125,330);*/
                   //button.addEventListener (MouseEvent.CLICK,sendMsg);
                   //addChild (button);
                   /*outputText = new TextField();
                   outputText.x = 10;
                  outputText.y = 10;
                  outputText.background = true;
                  outputText.autoSize = TextFieldAutoSize.LEFT;




                   rtmpGo = "rtmp://";
                   nc = new NetConnection( );
                   nc.connect (rtmpGo);
                   nc.addEventListener (NetStatusEvent.NET_STATUS,doSO);
              private function keyHandler(event:KeyboardEvent):void {
                      var curKeyCode:int = event.keyCode;
                      if (curKeyCode == 13) {


              private function doSO (e:NetStatusEvent):void
                   good=e.info.code == "NetConnection.Connect.Success";
                   if (good)
                         //Set up shared object
                         text_so.connect (nc);
                         text_so.addEventListener (SyncEvent.SYNC, checkSO);
              private function checkSO (e:SyncEvent):void
                   for (var chng:uint; chng<e.changeList.length; chng++)
                         switch (e.changeList[chng].code)
                              case "clear" :


                              case "success" :
                                   trace (text_so.data.msg);


                              case "change" :
                                   textAreaChat.text = text_so.data.msg + "\n";


              private function sendMsg (e:MouseEvent):void
                  noName= (textInput.text=="");
                   if (noName)
                  //textAreaChat.htmlText += textInput.text + "\n";
                   text_so.setProperty ("msg", textInput.text);
                   textAreaChat.appendText (textInput.text + "\n");
                   textInput.text = "";
              private function sendMsg1 ():void
                  noName= (textInput.text=="");
                   if (noName)
                   text_so.setProperty ("msg",textInput.text);
                   outputText.appendText (textInput.text + "\n");
                   textInput.text = "";