3 Replies Latest reply on Feb 27, 2010 8:56 PM by rcanulla

    currentState changes, but display list doesn't update

    rcanulla Level 1

      Hi there,

       

      Anyone ever ran into somethng like this?

       

      Thanks in advance!

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" horizontalAlign="center" verticalAlign="middle" creationComplete="init()">
           <mx:Script>
                <![CDATA[
                     import mx.collections.ArrayCollection;
                     import flash.net.navigateToURL;
                     import com.ryancanulla.dashboard.login.events.LoginEvent;
                     
                     private var _availableClients:ArrayCollection;
                     
                     private function init():void{
                          //onChooseActiveClient();
                          //currentState = "ChooseClient";
                          // add event listener for enter key to submit form
                          //this.addEventListener(KeyboardEvent.KEY_DOWN
                     }
                     public function get availableClients():ArrayCollection{
                          return _availableClients;
                     }
                     public function set availableClients(e:ArrayCollection):void{
                          _availableClients = e as ArrayCollection
                     }
                                    
                     private function logUserIn():void {
                          
                          var loginEvent:LoginEvent = new LoginEvent(LoginEvent.LOGIN);
                          loginEvent.userCredentials.userEmail = emailInput.text;
                          loginEvent.userCredentials.userPassword = passwordInput.text;
                          
                          dispatchEvent(loginEvent);
                          
                          emailInput.text = "";
                          passwordInput.text = "";
                     }
                     
           ------------>   public function onChooseActiveClient():void{
                          trace(this.currentState); // traces null
                          this.currentState = "ChooseClient";
                          trace(this.currentState); // traces ChooseClient
                          
                     }     
                
                
                ]]>
           </mx:Script>
                <mx:states>
                <mx:State name="ChooseClient">
                     <mx:RemoveChild target="{emailInput}"/>
                     <mx:RemoveChild target="{label1}"/>
                     <mx:RemoveChild target="{passwordInput}"/>
                     <mx:RemoveChild target="{label2}"/>
                     <mx:RemoveChild target="{linkbutton1}"/>
                     <mx:RemoveChild target="{button1}"/>
                     <mx:SetProperty target="{textarea1}" name="text">
                          <mx:value>Please choose what client you would like to manage.</mx:value>
                     </mx:SetProperty>
                </mx:State>
           </mx:states>
           <mx:Panel width="326" height="214" layout="absolute" title="Brodeur Dashboard">
                <mx:Label x="45" y="69" text="Email:" id="label1"/>
                <mx:Label x="24" y="100" text="Password:" id="label2"/>
                <mx:TextInput x="100" y="66" id="emailInput"/>
                <mx:TextInput x="100" y="97" id="passwordInput" displayAsPassword="true"/>
                <mx:Button x="211" y="131" label="Log In" click="logUserIn()" id="button1"/>
                <mx:TextArea x="10" y="17" width="260" editable="false" borderStyle="none" height="34" id="textarea1">
                     <mx:text><![CDATA[Login to begin using the Brodeur Partners monitoring dashboard.
      ]]></mx:text>
                </mx:TextArea>
                <mx:LinkButton x="2" y="150" label="Need Help?" click="{navigateToURL(new URLRequest('mailto:rcanulla@brodeur.com'))}" id="linkbutton1"/>
           </mx:Panel>
           
      </mx:VBox>
      
      
        • 1. Re: currentState changes, but display list doesn't update
          rcanulla Level 1
          <?xml version="1.0" encoding="utf-8"?>
          <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" horizontalAlign="center" verticalAlign="middle" creationComplete="init()">
               <mx:Script>
                    <![CDATA[
                         import mx.collections.ArrayCollection;
                         import flash.net.navigateToURL;
                         import com.ryancanulla.dashboard.login.events.LoginEvent;
                         
                         private var _availableClients:ArrayCollection;
                         
                         private function init():void{
                              //onChooseActiveClient();
                              //currentState = "ChooseClient";
                              // add event listener for enter key to submit form
                              //this.addEventListener(KeyboardEvent.KEY_DOWN
                         }
                         public function get availableClients():ArrayCollection{
                              return _availableClients;
                         }
                         public function set availableClients(e:ArrayCollection):void{
                              _availableClients = e as ArrayCollection
                         }
                                        
                         private function logUserIn():void {
                              
                              var loginEvent:LoginEvent = new LoginEvent(LoginEvent.LOGIN);
                              loginEvent.userCredentials.userEmail = emailInput.text;
                              loginEvent.userCredentials.userPassword = passwordInput.text;
                              
                              dispatchEvent(loginEvent);
                              
                              emailInput.text = "";
                              passwordInput.text = "";
                         }
                         
               ------------>   public function onChooseActiveClient():void{
                              trace(this.currentState); // traces null
                              this.currentState = "ChooseClient";
                              trace(this.currentState); // traces ChooseClient
                              
                         }     
                    
                    
                    ]]>
               </mx:Script>
                    <mx:states>
                    <mx:State name="ChooseClient">
                         <mx:RemoveChild target="{emailInput}"/>
                         <mx:RemoveChild target="{label1}"/>
                         <mx:RemoveChild target="{passwordInput}"/>
                         <mx:RemoveChild target="{label2}"/>
                         <mx:RemoveChild target="{linkbutton1}"/>
                         <mx:RemoveChild target="{button1}"/>
                         <mx:SetProperty target="{textarea1}" name="text">
                              <mx:value>Please choose what client you would like to manage.</mx:value>
                         </mx:SetProperty>
                    </mx:State>
               </mx:states>
               <mx:Panel width="326" height="214" layout="absolute" title="Brodeur Dashboard">
                    <mx:Label x="45" y="69" text="Email:" id="label1"/>
                    <mx:Label x="24" y="100" text="Password:" id="label2"/>
                    <mx:TextInput x="100" y="66" id="emailInput"/>
                    <mx:TextInput x="100" y="97" id="passwordInput" displayAsPassword="true"/>
                    <mx:Button x="211" y="131" label="Log In" click="logUserIn()" id="button1"/>
                    <mx:TextArea x="10" y="17" width="260" editable="false" borderStyle="none" height="34" id="textarea1">
                         <mx:text><![CDATA[Login to begin using the Brodeur Partners monitoring dashboard.
          ]]></mx:text>
                    </mx:TextArea>
                    <mx:LinkButton x="2" y="150" label="Need Help?" click="{navigateToURL(new URLRequest('mailto:rcanulla@brodeur.com'))}" id="linkbutton1"/>
               </mx:Panel>
               
          </mx:VBox>
          
          
          
          • 2. Re: currentState changes, but display list doesn't update
            Flex harUI Adobe Employee

            I don't know when onChooseActiveClient gets called so it could be timing,

            but I think in Flex 3, currentState can be null.

            • 3. Re: currentState changes, but display list doesn't update
              rcanulla Level 1

              It gets called on the result of a service call. It is in fact getting called... How could timing come into play?