3 Replies Latest reply on May 1, 2009 6:55 AM by ATIF FAROOQ

    State transitions from Modules

    bcnice

      My application.mxml defines my state transitions and loads a couple of modules at startup - GuestSearch and GeneralInformation. In the GuestSearch, there is a button that when clicked, should remove the GeneralInformation module on the right and replace it with a different third module, GuestSearchResults. I'm new to Flex, so I haven't quite got my mind around the proper way to handle application flow.

       

      [application.mxml]

          <mx:states>
              <mx:State name="GuestSearch"> // initial state
                  <mx:AddChild relativeTo="{leftSide}" position="lastChild">
                      <states:GuestSearch/>
                  </mx:AddChild>
                  <mx:AddChild relativeTo="{rightSide}" position="lastChild">
                      <states:GeneralInformation/>
                  </mx:AddChild>
              </mx:State>
              <mx:State name="GuestSearchResults"> // state to go to after button click in module1
                  <mx:RemoveChild target="{rightSide}"/>
                  <mx:AddChild relativeTo="{rightSide}" position="lastChild">
                      <states:GuestSearchResults/>
                  </mx:AddChild>
              </mx:State>
          </mx:states>

       

          <mx:Canvas x="0" y="54" width="100%" height="100%" backgroundColor="#8591C2">
              <mx:constraintColumns>
                  <mx:ConstraintColumn id="col1" width="300"/>
                  <mx:ConstraintColumn id="col2" width="100%" />
              </mx:constraintColumns>
              <mx:Canvas id="leftSide" left="col1:7" top="9" bottom="9" right="col1:4"/>
              <mx:Canvas id="rightSide" left="col2:4" top="9" bottom="9" right="col2:7"/>
          </mx:Canvas>

       

      My question is since this information is defined in my application.mxml, how can clicking on the button in the GuestSearch module reference the states defined in the application.mxml so as to swap modules?

       

      Thanks for the help

      Brian