1 Reply Latest reply on Nov 22, 2011 1:08 PM by scottyhrogers

    Dispacting navigation events from creation complete.

    scottyhrogers

      Why does this event work if it's triggered from a button (Changing a viewstack event)

       

      <<BUTTON CODE>>

      <mx:Button id="linkToReg"

                                     label="Need to Register?"

                                    click="clickToRegistrationHandler(event)"

                                     visible="{modelLocator.isNetworkAvailable &amp;&amp; modelLocator.adminId >0}"

                                     includeInLayout="{modelLocator.isNetworkAvailable &amp;&amp; modelLocator.adminId >0}"

                                     />

       

      <<FUNCTION FOR BUTTON>>

      protected function clickToRegistrationHandler(event:MouseEvent):void

      {

      dispatchEvent(new NavigationEvent(NavigationEvent.NEED_REGISTER));

      }

       

      But when I try to trigger the dispatchEvent from a completionComplete funtion it doesn't work?

       

      <<CREATION COMPLETE TRIGGER>>

      <views:LoginViewBase

          xmlns:fx="http://ns.adobe.com/mxml/2009"

          xmlns:s="library://ns.adobe.com/flex/spark"

          xmlns:mx="library://ns.adobe.com/flex/mx"

          xmlns:views="com.merceradvisors.views.*"

          width="100%"

          height="100%"

          creationComplete="loginviewbase1_creationCompleteHandler(event)"

          >

       

      <<CREATION COMPLETE FUNTION>>

      protected function loginviewbase1_creationCompleteHandler(event:FlexEvent):void

                  {

                      var sharedObj:SharedObject=SharedObject.getLocal("Login_Mercer")

                      // here checking if the variable sored exists in shared object

                      if(sharedObj.data.email!=undefined && sharedObj.data.password!="")

                      {

                          email.text=sharedObj.data.email;// adding the text value of the

                          password.text=sharedObj.data.password;// adding the text value of the login in the shared object

                      }

                      trace("Triggered Successfully1");

                      dispatchEvent(new NavigationEvent(NavigationEvent.NEED_REGISTER));

                      trace("Triggered Successfully2");

       

                  }

       

      This works just fine when triggered in a button and the viewstack changes, but when its programaticly triggered from creation complete it doesnt work.  Once I get this working I want to check a condition. if this then>>trigger this event

       

       

      <<CREATION COMPLETE FUNTION WITH CONDITION>>

      protected function loginviewbase1_creationCompleteHandler(event:FlexEvent):void

                  {

                      var sharedObj:SharedObject=SharedObject.getLocal("Login_Mercer")

                      // here checking if the variable sored exists in shared object

                      if(sharedObj.data.email!=undefined && sharedObj.data.password!="")

                      {

                          email.text=sharedObj.data.email;// adding the text value of the

                          password.text=sharedObj.data.password;// adding the text value of the login in the shared object

                      }

                      if(modelLocator.adminId == 0 )

                      {

                          dispatchEvent(new NavigationEvent(NavigationEvent.REGISTER_NEW));

                      }

                      else

                      {

                          dispatchEvent(new NavigationEvent(NavigationEvent.LOGOUT));

                      }

       

                  }