0 Replies Latest reply on Mar 22, 2010 3:12 AM by quoc_thai

    Add new data into AdvancedDataGrid from socket.

    quoc_thai

      Hi all,

       

         I wrote socket web to communicate beetween flex and java server by xml format. And something ok ! But, I meet a problem is process data that received from socket. My code section such as:

       

      [

      Bindable]

       

      private var xmlListPrice:XMLListCollection;

      [

      Bindable]

       

      public var arrStock:ArrayCollection = new ArrayCollection([]);

       

      private function configureListeners(dispatcher:IEventDispatcher):void{

          .....

           dispatcher.addEventListener(DataEvent.DATA, dataHandler);

      }

       

       

      public function dataHandler(result:DataEvent):void {

      var

      result:XML = XML(event.data);

       

      if (result.name() == "su"){     // get the tag name

       

      var resultArray:Array;

       

      if (xmlListPrice != null){

      xmlListPrice.addItem(result);

      arrStock.addItem(xmlListPrice.toArray());

      grdMainBoard.dataProvider = arrStock;         // Not effect !

       

      }

       

      else{

      xmlListPrice =

      new XMLListCollection();

      xmlListPrice.addItem(result);

      arrStock.source = xmlListPrice.toArray();

      grdMainBoard.dataProvider = arrStock;     // set first data is ok.