3 Replies Latest reply on Jul 30, 2009 10:59 AM by Gregory Lafrance

    Component Refresh

    Travis Lazar

      I'm creating a dashboard and ran into a small problem. I have 5 charting components that are each built custom and pull from various databases through webservices which all works fine and well. However, there are a few context sensitive global variables that can be set by the user at run time. When the user changes one of these global variables I want to refresh one or more of my custom components completely, as if the component was being launched all over again. How can I accomplish this?


      My alternative is to create some sort of 'refresh()' function myself within each component and have it repull the data with the new variables but I was looking for an easier way to accomplish the task.

        • 1. Re: Component Refresh
          Gregory Lafrance Level 6

          I would put the global variables in an ArrayCollection, and add an event listener to the collection for the collectionChange event.


          Then each of your components can have a reset() method that resets that component to your desired condition.


          If any of the variables in the AC change, the event is fired, the event handler calls a global reset(), and call the reset() method for the the components to reset.


          If this post answered your question or helped, please mark it as such.

          • 2. Re: Component Refresh
            Travis Lazar Level 1

            Right, that is similar to my option 2. I am trying to get around writing a refresh function for each component. I'm looking for a way to 'destroy' and 'reinstantiate' each component, as if I were to hit the refresh button on my browser (but instead of the entire application refreshing I want the individual component to refresh).

            • 3. Re: Component Refresh
              Gregory Lafrance Level 6

              You could put all the components inside a custom container component, and when you want to refresh, in ActionScript set that custom container component to null, and then reinstantiate it.


              If this post answered your question or helped, please mark it as such.