6 Replies Latest reply on Jul 9, 2007 4:41 PM by csawall

    RemovePopUp command from parent application (not the popup).

    csawall
      I am trying to remove a popup from the main application instead of the popup window. This way the window will close when they change tabs within the app or reclick the button. I can get it to close from within the popup with this statement just fine: PopUpManager.removePopUp(this).

      But shouldn't I be able to just use the same command with the object name to close it from the app itself, like this? PopUpManager.removePopUp(helpinfopop).

      I've searched this forum and Google and can't come up with anyone doing this. Everyone closes the popup from within the popup itself.

      private function showHelp():void {
      if(shHelp=="false"){
      shHelp="true";
      var helpinfopop:helpinfo = helpinfo(PopUpManager.createPopUp(this, helpinfo, false));
      helpinfopop.title="Help";
      helpinfopop.showCloseButton=true;
      helpinfopop.hscreen=allinfo.selectedChild.name;
      PopUpManager.centerPopUp(helpinfopop);
      }
      else {
      shHelp="false";
      PopUpManager.removePopUp(helpinfopop);
      }
      }

      Thanks in advance.

      Chris
        • 1. Re: RemovePopUp command from parent application (not the popup).
          Mitek17
          Hi Chris,

          RemovePopUp works from the parent window.
          I think that your problem is in the way you store the popup window variable.
          var helpinfopop:helpinfo

          You should declare this variable in the global scope or use static keyword. Currently it is an unintialised local variable when you call this function second time.

          Cheers,

          Dmitri.
          • 2. Re: RemovePopUp command from parent application (not the popup).
            csawall Level 1
            Dmitri - Thanks for the help, but I'm still having some problems. I've tried the following two ways:

            private function showHelp():void {
            var helpinfopop:helpinfo; <------ MOVED IT UP
            if(shHelp=="false"){
            shHelp="true";
            helpinfo(PopUpManager.createPopUp(this, helpinfo, false));
            helpinfopop.title="Help";
            helpinfopop.showCloseButton=true;
            helpinfopop.hscreen=allinfo.selectedChild.name;
            PopUpManager.centerPopUp(helpinfopop);
            }
            else {
            shHelp="false";
            PopUpManager.removePopUp(helpinfopop);
            }
            }

            *************************
            public var helpinfopop:helpinfo; <----- MOVED IT UP AND OUT
            private function showHelp():void {
            if(shHelp=="false"){
            shHelp="true";
            helpinfo(PopUpManager.createPopUp(this, helpinfo, false));
            helpinfopop.title="Help";
            helpinfopop.showCloseButton=true;
            helpinfopop.hscreen=allinfo.selectedChild.name;
            PopUpManager.centerPopUp(helpinfopop);
            }
            else {
            shHelp="false";
            PopUpManager.removePopUp(helpinfopop);
            }
            }

            In both scenarios, I get a new error stating that it "Cannot access a property or method of a null object reference." In both cases it is referencing the line: helpinfopop.title="Help".

            I'm assuming I'm doing something else wrong. I was really starting to get the hang of Flex. I've been using it for about 5 months now. But apparently I'm missing something.....

            Thanks for the help so far. I look forward to your response.

            Chris
            • 3. Re: RemovePopUp command from parent application (not the popup).
              csawall Level 1
              Further troubleshooting - still the same problem.

              By doing the following, I am back to the original problem where it just won't close the popup.

              public static var helpinfopop:helpinfo;
              private function showHelp():void {
              if(shHelp=="false"){
              shHelp="true";
              var helpinfopop:helpinfo = helpinfo(PopUpManager.createPopUp(this, helpinfo, false));
              helpinfopop.title="Help";
              helpinfopop.showCloseButton=true;
              helpinfopop.hscreen=allinfo.selectedChild.name;
              PopUpManager.centerPopUp(helpinfopop);
              }
              else {
              shHelp="false";
              PopUpManager.removePopUp(helpinfopop);
              }
              }

              I tried it with and without "static" in the initial setting of the "public var" before the function. I also tried it with and without this within the function "var helpinfopop:helpinfo = ". With it, the popup works, but I can't use the RemovePopUp function. Without it, I get the error from the previous post.

              Thoughts?

              Thanks,
              chris
              • 4. Re: RemovePopUp command from parent application (not the popup).
                csawall Level 1
                Resolved. Here is the final code. The key was to do as Mitek17 suggested and I made a public var of helpinfopop:helpinfo. The next thing, after much trial and error was to change this line:

                var helpinfopop:helpinfo = helpinfo(PopUpManager.createPopUp(this, helpinfo, false));

                to this:
                helpinfopop = helpinfo(PopUpManager.createPopUp(this, helpinfo, false));

                The whole snippet of code:

                public var helpinfopop:helpinfo;
                private function showHelp():void {
                if(shHelp=="false"){
                shHelp="true";
                helpinfopop = helpinfo(PopUpManager.createPopUp(this, helpinfo, false));
                helpinfopop.title="Help";
                helpinfopop.showCloseButton=true;
                helpinfopop.hscreen=allinfo.selectedChild.name;
                PopUpManager.centerPopUp(helpinfopop);
                }
                else {
                shHelp="false";
                PopUpManager.removePopUp(helpinfopop);
                }
                }
                • 5. RemovePopUp command from parent application (not the popup).
                  dimival Level 1
                  EDIT: Never mind, you solved it while i was typing this :P

                  Try it like this:

                  private function showHelp():void {
                  var helpinfopop:helpinfo;
                  if(shHelp=="false"){
                  shHelp="true";
                  helpinfo = new helpinfo();
                  helpinfo = helpinfo(PopUpManager.createPopUp(this, helpinfo, false));
                  helpinfopop.title="Help";
                  helpinfopop.showCloseButton=true;
                  helpinfopop.hscreen=allinfo.selectedChild.name;
                  PopUpManager.centerPopUp(helpinfopop);
                  }
                  else {
                  shHelp="false";
                  PopUpManager.removePopUp(helpinfopop);
                  }
                  }
                  • 6. Re: RemovePopUp command from parent application (not the popup).
                    csawall Level 1
                    Thanks dimival - That's pretty close to what I ended up doing (see above). Thank you for the suggestion. If I run into problems, I'll try your idea.

                    chris