1 Reply Latest reply on Mar 17, 2010 1:09 PM by AdrianWiecek

    How can I do an onload when a state changes?

    Asahart-XEvNWS Level 1

      I need to make a call for data each time the state changes. Where do I place the code that calls the function? In the state definition?

       

      Thank for your help in advance.

        • 1. Re: How can I do an onload when a state changes?
          AdrianWiecek Level 3

          Hi,

           

          You can use StateChangeEvent.CURRENT_STATE_CHANGE, or StateChangeEvent.CURRENT_STATE_CHANGING:

           

          <?xml version="1.0" encoding="utf-8"?>

          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"

               currentStateChange="currentStateChangeHandler(event)">

           

               <mx:Script>

                    <![CDATA[

                         import mx.events.StateChangeEvent;

                         private function currentStateChangeHandler(event:StateChangeEvent):void

                         {

                              //place your code here

                         }

                    ]]>

               </mx:Script>

           

          </mx:Application>

           

          Regards,

          Adrian