2 Replies Latest reply on Jun 5, 2006 10:36 AM by ntsiii

    referencing 'states' in another component

    Lokesh_Dhakar
      Relevant file structure:
      Main.mxml (main app file)
      \myComponents\Login.mxml (custom component)

      In my Main.mxml file I have three states:
      <Base state>
      Login (start)
      Home

      On clicking a Submit button in the Login.mxml component I would like to have the Main.mxml's state switch to Home. How would I go about referencing the Home state from the Login.mxml custom component (which is placed in the Login state). The questions boils down to targetting syntax. Any help is appreciated, thank you.
        • 1. Re: referencing 'states' in another component
          FredFlex
          Hi,

          I'm not sure to understand what you want to do but:

          to have the Main.mxml's state switch to Home by clicking a Submit button in the Login.mxml component I would do the following:

          - in your Main.mxml make a public function (witch change state) that you call from Login.mxml
          Ex:
          Main.mxml :
          <mx:Application id="main" xmlns:mx=" http://www.adobe.com/2006/mxml">
          ...
          public function changestate():void {
          ....//change state function
          }

          Login.mxml :
          private function OnClick_submit(e:event):void {
          //call main.mxml function to change state
          main.changestate();
          }
          • 2. Re: referencing 'states' in another component
            ntsiii Level 3
            When working with components, the file structure does not matter. What is important is the component/object structure of the running application.

            In your case, what is the run-time relationship between login.mxml and main.mxml? Who is the child? If main is a child of login, then FredFlex is correct.

            If Login is a child of main, then you would do:
            mx.core.Application.application.changestate();

            Tracy