1 Reply Latest reply on May 5, 2013 9:10 AM by kglad

    how to refresh datagrid automatically

    guztraij

      I want to built a multiplayer game, so i put a datagrid to show all available room, so for some user who not create a room they can just join the room by clicking it at the datagrid.
      Im using sql database and php to parse some variable to show what data that i want on flash..

       

      This is my as2 at frame"room" to show a datagrid. It work fine when i go to this frame at the first time.

      loadAllRoom_lv.id_user = id_login;

      loadAllRoom_lv.sendAndLoad(filepath+ "MULTI_gridAllRoom_data.php",loadAllRoom_lv,"POST")

      loadAllRoom_lv.onLoad=function()

      {

                var dataNoRoom:Array = loadAllRoom_lv.no_score.split(",",loadAllRoom_lv.baris);

                var dataRoomName:Array = loadAllRoom_lv.room_name.split(",",loadAllRoom_lv.baris);

                var dataRoomMaster:Array = loadAllRoom_lv.room_master.split(",",loadAllRoom_lv.baris);

                var dataRoomStatus:Array = loadAllRoom_lv.room_status.split(",",loadAllRoom_lv.baris);

                for (var i=0; i<loadAllRoom_lv.baris; i++)

                {

                            arrayRoom.addItem({NO:dataNoRoom[i], ROOM_NAME:dataRoomName[i], ROOM_MASTER:dataRoomMaster[i], STATUS:dataRoomStatus[i]});

                }

           grid_allRoom.dataProvider = arrayRoom;

           grid_allRoom.setSize(540, 300);

           grid_allRoom.rowHeight = 30;

           grid_allRoom.getColumnAt(0).width = 40;

           grid_allRoom.getColumnAt(1).width = 200;

           grid_allRoom.getColumnAt(2).width = 200;

           grid_allRoom.getColumnAt(3).width = 100;

      }

       

      For example, there are 2 user on line at same server..

      they access the game at the same time..
      "Alan" create a room, and "Brian" directly view the room list..
      Firstly, Brian not seeing Alan's room (since it not yet created).
      But then, when Alan finish creating room, Brian can view Alan's room at the datagrid.

       

      My problem is here..

      Brian didn't see the room which created by Alan at the datagrid because the datagrid only show the data which Alan's room not yet created..

       

      My conclusion..
      I have to refresh the datagrid automatically!

       

      My question..

      How to refresh the datagrid automatically or periodicly?

      What should i do? Use timer? Or some one there have any solution, so i don't have to put a refresh button to do "that refresh stuff".


      Share me your link, source code, and knowledge.. Thx..