3 Replies Latest reply on Apr 29, 2009 11:48 AM by bobskid

    Flex State manipulation


      is there a way to change states from within a particular state?


      if i define my different states in a main.mxml file how do i change states from a state that i switch to.


      for example i have a login button that changes state to a login screen --- when you click the submit button i want to switch to

      a different state only that state is defined back in my main.mxml file??  is there an easy way to do this?

        • 1. Re: Flex State manipulation
          ATIF FAROOQ Level 3


             currentState='your sate name' this is the general method to switch from one state to antoher

          • 2. Re: Flex State manipulation
            Gregory Lafrance Level 6

            This code should help:


            ----------- MyVBox.mxml ---------------

            <?xml version="1.0" encoding="utf-8"?>
            <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" horizontalAlign="center">
              <mx:Label text="Component State"/>
              <mx:Button label="Main State" click="mx.core.Application.application.currentState=''"/>


            --------- MainApp.mxml --------------

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
              xmlns:comp="*" horizontalAlign="center" width="100%" height="100%">

              <mx:Label id="lbl" text="Main State"/>
                <mx:State name="componentState">
                  <mx:RemoveChild target="{lbl}"/>
                  <mx:RemoveChild target="{chgBtn}"/>
              <mx:Button id="chgBtn" label="Component State" click="currentState='componentState'"/>

            • 3. Re: Flex State manipulation
              bobskid Level 1

              Thank you so much for your quick responses -- the mx.core.Application.application.currentState did the trick!!


              Much appreciated!