6 Replies Latest reply on Feb 20, 2015 7:05 AM by kglad

    I need an AS2 button that closes out a pop-up window...

    Tic.Toc

      So, I’ve constructed a portfolio site with ActionScript 2.0, but I would like the pop-up window that displays the portfolio image to have its own ‘X’ button that closes the swf movie from the browser.  I’m assuming that the code begins something like this:

       

      on(release){

      //actionscript 2.0 code that closes the browser window.

      }

       

      Any suggestions on how this will work across platforms and browsers?

      Best,

      R.

        • 1. Re: I need an AS2 button that closes out a pop-up window...
          kglad Adobe Community Professional & MVP

          how do you create the popup?  ie, show the code used.

          • 2. Re: I need an AS2 button that closes out a pop-up window...
            Tic.Toc Level 1

            Hi kglad,

             

            My main flash as2 file has a stage size of 1200 width x720 height.  I’ve looked online through various methods on creating pop-up browsers that will display a portfolio image when a button on the main.swf is clicked.  Having no luck in finding what I needed (most tutorials just give getURL examples where the image is displayed in a separate tab), it finally dawned on me to create an overlaying movie, of the same size as the document size, on the top layer of the primary flash stage.  Setting the movie symbol as ‘invisible’ keeps the movie symbol inactive and invisible until called by an action.  The button on the main.swf that calls the movie has the following as2 script attached to it:

             

            on(release){

                           loadMovie("images/aauComp.swf", _root.movie2);

            }

             

            However, the aauComp.swf file is where the exit button is located.  I need to implement an on(release){} method onto the exit button in aauComp.swf  that will close the movie out in the main.swf file.  Here’s the double wammy, though: the exit button on the called movie file, aauComp.swf, does not recognize any gotoAndStop(); or on(release){} functions relating to itself when it is loaded. For instance, since I could not find any functions that would close the movie out and return me to the main.swf interface, I wrote the following command on the ‘exit’ button in aauComp.swf:

             

            on(release){

                           _root.gotoAndStop("blank_frame");

            }

             

            Where “blank_frame” is within a scene of aauComp.swf that is completely empty – which should, in theory, allow for interaction with the main.swf below the loaded movie since there is nothing on that layer of the loaded aauComp.swf movie.  Make sense?  The ‘exit’ button works fine when aauComp.swf is tested and published by itself, but when it is called into the main.swf with the loadMovie(); function, the 'exit' button will not work and, so, it will not forward to the “blank_frame”.

            Any suggestions?  Let me know if you need anything clarified.

            Thanks.

            • 3. Re: I need an AS2 button that closes out a pop-up window...
              kglad Adobe Community Professional & MVP

              if you use loadMovie() to create your 'popup', use unloadMovie() to remove the loaded swf or swap depths (if needed) of _root.movie2 and use removeMovieClip().

               

              if you use a goto to create your 'popup', use another goto to make it appear as if it's removed.

              1 person found this helpful
              • 4. Re: I need an AS2 button that closes out a pop-up window...
                Tic.Toc Level 1

                I tried it, but I don't think the unloadMovie() method is going to work because the 'close' button is within the loaded movie itself.  The movie needs to close itself out rather than a button on the main.swf layer.  I feel like there should be a 'this.' syntax somewhere to let the 'close' button within the movie know that it needs to refer to the movie, and not the main.swf that called it.

                 

                I did try this idea:

                I attached the following code to the 'close' button with the aauComp.swf loaded movie:

                 

                on(release){

                _root.gotoAndPlay(13);

                }

                 

                This code will close out the movie and revert back to the 13th frame of the main.swf.  I tried also replacing 13 with 15 and the movie closes out and reverts to the 15th frame.  As you might have guessed, frame 14 is where main.swf loads images/aauComp.swf into the movie2.  I would simply attach the code:

                 

                on(release){

                _root.gotoAndPlay(14);

                }

                 

                but it does not refresh the frame and the movie remains open.  Is there any syntax that might look like either of these? (i know these would not compile)

                 

                on(release){

                     this.gotoAndPlay("blank_frame);

                }

                OR

                on(release){

                     refresh._root.gotoAndPlay(14);

                }

                 

                Thanks

                • 5. Re: I need an AS2 button that closes out a pop-up window...
                  Tic.Toc Level 1

                  I got it to work.  I’ll admit, it was a cob-job and it’s not as clean as I would have liked.  I set the ‘close’ button code within the called loadMovie aauComp.swf to read:

                  On(release){

                  _root.gotoAndPlay(“frame3_published”);

                  }

                  Where “frame3_published” is the frame label name within main.swf from which the loadMovie was called.  I simply made a duplicate frame directly after frame3_published, so that the main.swf will stop(); at the following frame.  In effect, the ‘close’ button calls the frame directly before frame3_published so that it looks like it refreshes the page when it is actually just playing to the next frame that is a duplicate of it.  Hope this makes sense.  If not, my apologies; it’s late and my eyes are half open. 

                  Thanks for your continued suggestions, though.