8 Replies Latest reply on Sep 21, 2006 12:13 PM by kglad

    What ActionScript quits/exits/closes a SWF?

    mgschange Level 1
      To offer a user the chance to quit the Flash application and return to the web site, I have a button. What ActionScript do I attach to the button in order to quit the swf and close the window it is in?
        • 1. Re: What ActionScript quits/exits/closes a SWF?
          DazFaz Level 1
          on(release){
          getURL("Javascript:window.close()");
          }
          • 2. Re: What ActionScript quits/exits/closes a SWF?
            Level 7
            You cannot quit or close from a SWF running in a web page .. that really
            makes no sense.

            All you can do is close the web page it is playing in (via Javascript)

            Or you can turn your SWF into an executable program (projector) that runs on
            a PC or Mac, and you can tell that program to close itself via fscommand.
            --
            Jeckyl


            • 3. Re: What ActionScript quits/exits/closes a SWF?
              mgschange Level 1
              This is my first Flash effort. My application is a detailed 40 minute survey that users will find on my web site. So they click on the button and up comes my survey, loaded from another swf. They take the survey and want to quit.

              When they quit I want to 1) close the swf and 2) send out to my email survey data that I have stored in an Array.
              What do developers normally do for such a situation?
              Do most people just leave the swf running and link back to their site?
              Users may not complete the entire survey but I still want data about their visit that is stored in the array, so if they simply close the window using the X in the upper right corner, what "event" can I use to tell Flash to send my data?

              If recommended , I will explore this projector idea.
              • 4. Re: What ActionScript quits/exits/closes a SWF?
                Level 7
                > When they quit I want to 1) close the swf

                You cannot close a swf .. you can only close the web page in which it is
                playing, or go ot another web page

                > If recommended , I will explore this projector idea.

                Projector is a program (which you would have to distribute and users
                download and install) .. its not appropriate for a web-based app.
                --
                Jeckyl


                • 5. Re: What ActionScript quits/exits/closes a SWF?
                  kglad Adobe Community Professional & MVP
                  "...up comes my survey...". what code are you using to do that?
                  • 6. Re: What ActionScript quits/exits/closes a SWF?
                    mgschange Level 1
                    I have a container swf that creates movie clips and loads swfs into them. The first swf is a tease or advertisement for the survey. When this movie clip is clicked it brings in the survey which is called success tool.

                    This works fine but I do have a problem with it, which is that the sounds in my survey (user feedback sounds that play when survey answers are selected) turn off when the survey is loaded.

                    It sounds as though it's fine to just put a link on my exit button to simply navigate back to the web site, who cares if the swf is still running?

                    But what is the "closure" event I can use to trigger sending my data out of the swf to my email? That is, if the user closes the swf without finishing the survey, and therefore without getting to my exit button where I can attach ActionScript to send my data out, is there an event to which I can attach AS so that the data is sent whenever the close takes place? Or is there another way to handle this data which I need for market research and to build a database of survey responses?
                    • 7. Re: What ActionScript quits/exits/closes a SWF?
                      mgschange Level 1
                      I have a container swf that creates movie clips and loads swfs into them. The first swf is a tease or advertisement for the survey. When this movie clip is clicked it brings in the survey which is called success tool.

                      This works fine but I do have a problem with it, which is that the sounds in my survey (user feedback sounds that play when survey answers are selected) turn off when the survey is loaded.

                      It sounds as though it's fine to just put a link on my exit button to simply navigate back to the web site, who cares if the swf is still running?

                      But what is the "closure" event I can use to trigger sending my data out of the swf to my email? That is, if the user closes the swf without finishing the survey, and therefore without getting to my exit button where I can attach ActionScript to send my data out, is there an event to which I can attach AS so that the data is sent whenever the close takes place? Or is there another way to handle this data which I need for market research and to build a database of survey responses?
                      • 8. Re: What ActionScript quits/exits/closes a SWF?
                        kglad Adobe Community Professional & MVP
                        you can use the onChanged method of textfields to store up-to-date entries made to your input textfields. however, there is no way for flash to detect when the browser window closes.

                        there is javascript that can work for some browsers but it will be difficult to have something workable for most browser.

                        or you could periodically execute (using loadVariables or the LoadVars() class) your server-side code to store the variables defined at the time of execution.