2 Replies Latest reply on Jul 9, 2008 11:16 AM by webquorning

    Reload data when chaning view state

    webquorning
      Hi all,
      I have a main application ("MTF.mxml") and two view states in the application (myChallenges) and (responses). In the view states, I have inserted two customized components.

      The MyChallenges-component is a list of challenges and when a challenge is selected, I switch from the myChallenges-view state to the responses-view state using a costum event dispatcher.
      So far so good,

      The problem is that when I change to the responses-view state and therefore to my responses-component, the data loading on the panel of the component is only the request that I get when I for the first time enter the responses-component. When I go forward in my application from the responses-view state to the myChallenges-viewstate to pick a new challenge, the responses-view state does not reload with the new challenge id - actually, no action script code in the responses-component is processed at all!

      I figure it has something to do with the component's loading events.
      I use the creationComplete-tag property in the component to activate an init()-function to handle my ActionScript code. But this seems to activate the function only when the component is created for the first time!

      How do I handle this? I tried using the enterState-property, but with no succes!

      Please help me, if anyone knows the answer!
        • 1. Re: Reload data when chaning view state
          Sam Rowe
          Hi,

          I would expect the enterState event to work for what you need. e.g.

          where doStuff() is the method to load the new data.
          • 2. Re: Reload data when chaning view state
            webquorning Level 1
            Thank you for the quick feedback.
            The enterState-property works fine, it seems that the Action Script code loads every time.
            Actually, what I really wish is that the component "reloads" every time. The problem is that my actionscript code adds elements to the scene, edits properties and so forth, everything depending on what challengeId there is given to the component. When the component has completed the code once, variable-values, elements and so forth are still kept until the state is entered again. Is it not possible to actually reload the component - not just making "show/hide" it, as I do now?