Hi Everyone,
I have created a simple application with two views one for a login form and the 
other is main view that shows the application. To make the code readable I 
decided to put the view definition in separate files and call them from the 
Responsive View. I have defined the states of the app accordingly.
Main.mxml
<?xml version="1.0" encoding="utf-8"?><j:ApplicationResponsiveView 
xmlns:fx="http://ns.adobe.com/mxml/2009"    
xmlns:j="library://ns.apache.org/royale/jewel"    
xmlns:js="library://ns.apache.org/royale/basic"    
xmlns:html="library://ns.apache.org/royale/html"     
xmlns:mx="library://ns.apache.org/royale/mx"       xmlns:view="*" 
initComplete="initCompleteHandler(event)">
 <fx:Script>      <![CDATA[            
              private function initCompleteHandler(event:Event):void          { 
            trace("Main ResponsiveView is ready !!! ");
             trace(" set initial current state to log in ..");
                      currentState = 'login';       
           trace("  currentState: " + currentState);
        }
       ]]>     </fx:Script>          


 <j:states>              <js:State name="login" />                      
<js:State name="loggedIn" />               </j:states>
        <j:beads>                <js:SimpleStatesImpl/>        </j:beads>
            <view:LogIn includeIn="login">                       </view:LogIn>
   
    <j:ApplicationMainContent id="mainContent" hasTopAppBar="true" 
hasFooterBar="true" selectedContent="content" includeIn="loggedIn">             
  <j:SectionContent id="sc" name="content">                             
<view:Content>                            </view:Content>                  
</j:SectionContent>    </j:ApplicationMainContent>
</j:ApplicationResponsiveView>


The log in view is defined as follows
?xml version="1.0" encoding="utf-8"?><j:Card 
xmlns:fx="http://ns.adobe.com/mxml/2009"         
xmlns:j="library://ns.apache.org/royale/jewel"          
xmlns:js="library://ns.apache.org/royale/basic"          
xmlns:html="library://ns.apache.org/royale/html"           id="loginForm" 
x="60", y="60" height="50%">                <html:H1 text="Royale login"/>      
          <j:TextInput id="username" text="someuser"/>                
<j:TextInput id="password" text="somepass">                    <j:beads>        
                <j:PasswordInput/>                    </j:beads>                
</j:TextInput>                <j:Button text="Login" emphasis="primary" 
click="currentState = 'loggedIn'" /></j:Card>

Everything compiles fine. When I run the application and click log in button 
the view does not change to the Content view. In other words the button does 
not work.
However, If I embed the logIn.mxml inside the Main.mxml it works fine.

How can I access the Main.mxml current state from another file ?

Regards,

Reply via email to