3 Replies Latest reply on Feb 26, 2007 6:01 PM by ringx007

    question about 'currentState'

      2 mxml files

      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns:ns1="*" >
      private function login():void{
      this.currentState = 'main';
      <mx:Button id="btnLogin" label="Sign in" click="login()" />
      <mx:State name="main">
      <mx:RemoveChild target="{btnLogin}"/>
      <mx:AddChild position="lastChild">
      <ns1:main width="100%"></ns1:main>



      <?xml version="1.0" encoding="utf-8"?>
      <mx:Module xmlns:mx=" http://www.adobe.com/2006/mxml" >
      private function goback():void{
      this.currentState = '';
      <mx:Button click="goback()" cornerRadius="0"/>
      </mx:Module >
      How to go back the index.mxml when I click the button of main.mxml?

      seems this line doesnt play a role:
      this.currentState = '';

      Thx a lot !
        • 1. question about 'currentState'
          parent["currentState"] = '';
          Application.application["currentState"] = '';
          • 2. Re: question about 'currentState'
            newhander Level 1
            parent["currentState"] = '';
            works fine!

            why parent["currentState"] not parent.currentState?
            seems parent object doesnt have this property...
            • 3. Re: question about 'currentState'
              ringx007 Level 1
              Because type of parent is definded as "DisplayObjectContainer", "DisplayObjectContainer" doesn't have this property, but actually parent is "Application " here(DisplayObjectContainer is supper class of Application), so parent has "currentState", but "parent.currentState" will get compile error.
              it can be:
              UIComponent(parent).currentState = '';

              but i think the second way:Application.application["currentState"] = '' is better,
              if you add the "main" on a Container, the parent will not the application but this Container.

              if(Application.application && (Application.application is UIComponent)){
              UIComponent(Application.application).currentState = "":