1 Reply Latest reply on Jan 19, 2011 5:06 PM by drkstr_1

    redrawing objects at currentStateChange

    Maximist Level 1

      Hallo, i need a little help. When i call a new component with (for example) 3 states, after switched from state 1 to state 2 and back to state 1 i would like to redraw everything of the state 1 just like it is when i load the component the first time. I see that mxml code loads only 1 time... How can i force it everytime i back on that state??.. I hope you understood.

       

      Thx for all

       

      Max

        • 1. Re: redrawing objects at currentStateChange
          drkstr_1 Level 4

          Here is one possible solution...

           

          Listen for currentStateChanging and currentStateChange.

           

          protected function currentStateChangingHandler(event:StateChangeEvent):void
          {
               if(event.newState == "state1")
               {
                    this.currentState = null;
               }
          }
          
          
          protected function currentStateChangeHandler(event:StateChangeEvent):void
          {
               if(!event.newState)
               {
                    this.currentState = "state1";
               }
          }
          
          

           

          ...this may need to be cleaned up a bit, but you get the idea. Basically you need to set currentState to null to get the base state.

           

          ....

           

          on second thought this is reduntant. Why have state1 at all if you never intend to use it? Just get rid of it and use the base state in it's place.