3 Replies Latest reply on Sep 1, 2008 12:18 PM by yigitt

    Auto Refresh for updates

    fypstudent Level 1
      I'm doing a tilelist in the main mxml and it call the panels from another mxml just like http://livedocs.adobe.com/flex/2/docs/images/tilelist27.jpg.

      Each panel displays different information and it will update regularly. I did an auto-refresh by declaring a timer and resend all the panels from the database every 5 mins. However if a user is scrolling thru the list, and when it auto refreshes, the tile list will jump back to the original position (just like the scroll thumb will be back to the top) which will affect a lot on it's usability. any suggestions to prevent this from happening?

      What if i remove the auto-refresh and replace by function which will auto check for updates in the database and refreshes the tilist by itself? The only one that needs to be updated is actually a label text in each panel. If it updates, will it just change the text of each panel instead of the entire tilelist? in order to prevent the tilelist from jumping back.
      tks!
        • 1. Re: Auto Refresh for updates
          yigitt Level 1
          you, most probably, recreate the tileList dataProvider which would result in a jump back.
          instead of recreating the dataProvider, if you update the actual items, it will not jump back. So what I suggest is sth like:

          var cnt:int = 0;
          for each(newItem:MyObject in newList){
          (oldList.getItemAt(0) as MyObject).update(newItem);
          }

          update function in your MyObject class should look like:
          function update(other:MyObject):void {
          this.title = other.title;
          //copy other values
          }

          if the data length changes, your code should also be able to handle it. (trivial)
          • 2. Re: Auto Refresh for updates
            fypstudent Level 1
            Hi thank you for your reply, however where should i place the code? this is my actual layout of application Text, i actually place a inline itemRendereder in the <tilelist> tag, i also declare the dataprovider in it. thank you!
            • 3. Re: Auto Refresh for updates
              yigitt Level 1
              [Bindable]
              public var staff:ArrayCollection;
              public function resultHandler(event:ResultEvent):void{
              staff = event.result.staffsignage.staff;
              filterInit();
              }
              //-------------------------//
              // STAFFSTATUS drawing data for the tile list//
              //-------------------------//
              [Bindable]
              private var staffStatus:ArrayCollection;
              public function staffStatusHandler(event:ResultEvent):void{
              staffStatus = event.result.staffsignage.staff;
              }

              these two functions replaces the dataProvider.
              update these functions in the way i mentioned so that they will update the items inside staff & staffStatus arraycollections instead of updating the arraycollection references.
              so it should be sth like this:

              public function resultHandler(event:ResultEvent):void{
              if(!staff)
              staff = event.result.staffsignage.staff;
              else {
              var cnt:int=0;
              for each(var item:Object in event.result.staffsinage.staff){
              staff.getItemAt(cnt) = item;
              cnt++;
              }
              }
              filterInit();
              }
              you should also handle the cases when the new list length does not match the old list length.