1 Reply Latest reply on Dec 16, 2009 2:56 AM by Shivik

    States not displaying in Components

    Shivik Level 1

      Hello all

       

      I just created a main page - in which I created three views like this...

       

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:views="com.views.*">
           <views:Login />
           <views:Member />
      </mx:Application>
      

       

      Now in my LoginScreen I created a state like this...

       

      <mx:Box xmlns:mx="http://www.adobe.com/2006/mxml">
           <mx:Panel title="login" width="100%">
                <mx:VBox id="formContainer">
                     <mx:Form id="loginForm">
                          <!-- login form here -->
                     </mx:Form>
                </mx:VBox>
                <mx:Button label="Check State" click="currentState='error';" />
           </mx:Panel>
      
           <mx:states>
                <mx:State name="error">
                     <mx:AddChild relativeTo="{formContainer}">
                          <mx:VBox>
                               <mx:Label text="error occurred" /> 
                          </mx:VBox>
                     </mx:AddChild>
                </mx:State>
           </mx:states>
      </mx:Box>
      

       

      Upon pressing the "Check state" nothing gets displayed, even though in Flex Builder design view I can see the state.

       

      What am I doing wrong? Can somebody help me out here?

       

      Thanks and Regards

      ShiVik

        • 1. Re: States not displaying in Components
          Shivik Level 1

          Ok I have figured it out. I was doing like this...

           

          <mx:Box xmlns:mx="http://www.adobe.com/2006/mxml">
               <mx:Panel title="login" width="100%">
                    <mx:VBox id="formContainer">
                         <mx:Form id="loginForm">
                              <!-- login form here -->
                         </mx:Form>
                    </mx:VBox>
                    <mx:Button label="Check State" click="currentState='error';" />
               </mx:Panel>
          
               <mx:states>
                    <mx:State name="error">
                         <mx:AddChild relativeTo="{formContainer}"><mx:Spacer height="10" />
                              <mx:VBox>
                                   <mx:Label text="error occurred" /> 
                              </mx:VBox>
                         </mx:AddChild>
                    </mx:State>
               </mx:states>
          </mx:Box>

          I removed the spacer tag and it worked. SIlly me.