3 Replies Latest reply on Mar 21, 2011 7:52 PM by JMResler

    SWFLoading problem...

    JMResler

      Hi All,

          I have an application that loads and unloads multiple swf files dependent upon the role of the user.

      When I login to the app for the first time the web service calls all work fine. When I logout, I call the

      method SWFLoader.unloadAndStop();

       

      When the next user logs in, I load the dependent SWF (maybe reload the same one used previously)

      and proceed from there. The second time I login, clicking on the UI invokes type coercion errors.

      I would think these errors would show up with the first load but they do not. Does anyone have any

      useful suggestions? Thanks in advance.

       

      BTW, thanks to a guy whose login I can't recall but who solved a problem perfectly. Hopefully you

      know who you are.

       

      - JR

        • 1. Re: SWFLoading problem...
          Codeflayer

          Hi there,

           

          your description is a bit vague. It'd be helpful to have a stack trace. The

          first place I'd look is at the outside data you're trying to load. Is there

          some data that gets loaded from outside when the user logs in a second time?

           

          Good luck!

          • 2. Re: SWFLoading problem...
            Flex harUI Adobe Employee

            Probably the data types are registered on the first load and not

            re-registered on the second load then the data types cannot be converted.

             

            Try linking the data types into the main app.

            • 3. Re: SWFLoading problem...
              JMResler Level 1

              Maybe the code will help and how do I link datatypes into the main app?

               

               

              <fx:Declarations>

                   <userservice:Userservice id="userService"

                                                        useProxy="false"

                                                        fault="loginFaultHandler(event)"

                                                        result="loginHandler(event)"

                                                        showBusyCursor="true">

                   </userservice:Userservice>

              </fx:Declarations>

              ....
                   /*
                    *
                    */
                   private function loginHandler(event:ResultEvent) : void
                   {
                        user = new User();
                        if (event != null)
                        {
                             if (event.result.Id != 0 && event.result.UserType != "None")
                             {
                                  isLoggedIn = true;
                                  user.Id = event.result.Id;
                                  user.UserId = event.result.UserId;
                                  user.Name = event.result.Name;
                                  user.UserType = event.result.UserType;
                                  user.Token = event.result.Token;
                                  loginAttempts = 0;
                                  generalPurposeLabel.text = event.result.Name;
                                  userIDInput.text = "";
                                  passwordInput.text = "";
                                  currentState = 'logoutState';
                                  // dispatch login event here.
                                  var loginEvent:LoginEvent = new LoginEvent(user,loader);
                                  loginEvent.dispatch();
                             }
                            else
                             { // we had an invalid login
                                  generalPurposeLabel.text = loginFailedMessage;
                             }
                             userIDInput.text = "";
                             passwordLabel.text = "";
                             }    
                   }
                   /**
                     *
                     */
                    private function login(event:Event) : void
                   {
                        // are we already logged in?
                        if (currentState == "loginState")
                        {
                             // increment the login attempts
                             loginAttempts++;
                             if (loginAttempts >= maxLoginAttempts)
                             {
                                  // send locked out message
                                  generalPurposeLabel.text = exceededLoginCountMessage;
                                  // disable further attempts
                                  logBtn.enabled = false;
                                  userIDInput.enabled = false;
                                  passwordInput.enabled = false;
                                  return;
                             }
                                 
                                  // limited input validation
                                  // TODO - plugin validator later
                             if (  userIDInput.text.length == 0 ||
                                  passwordInput.text.length == 0)
                             {
                                  Alert.show("Please enter both user name\n and password to login.", "Login Failed", Alert.OK);
                                  generalPurposeLabel.text = "";
                                  return;
                             }
                       
                          try {
                                  userService.Authenticate(userIDInput.text, passwordInput.text);
                                  // userService.Authenticate.send();
                             } catch (error:Error) {
                                       Alert.show(error.toString(), "Web Service Connection Fault", Alert.OK);
                             }
                                  userIDInput.text = "";
                                  passwordInput.text = "";
                   }
                        else if (currentState == "logoutState")
                        {
                             logoutHandler(event);
                        }
                   }
                   private function logoutHandler(event:Event) : void
                   {
                        generalPurposeLabel.text = "";
                        currentState = "loginState";
                        loginAttempts = 0;
                        user.invalidateUser();
                        var logoutEvent:LogoutEvent = new LogoutEvent(user.Token, loader);
                        logoutEvent.dispatch();
                   }