Flash movie that self-closes new browser window

Here's some code you can add to your Flash files that will auto-close the new browser window. 

It's nothing more than some javascript adapted for Flash that tells the window to self close when the Flash file is finished playing.

How do you use the code?

Just add this code to a frame in Flash:

getURL("javascript:window.opener=self; window.close()");
Learn more:
10 Replies
David Anderson

HI Linda,

Did this movie/window open

I noticed that Chrome will block the window and not throw a message that it blocked the pop up. Firefox will tell you it blocked the pop up and give you the option to load the movie.

(Note the direct link to the movie won't close because it wasn't launched from the main, Presenter window)

David Anderson

The code is executed from within the .swf file. I don't know how it could be added to video files? That's a great question. I don't believe it can work in mp4 and probably not .flvs since those are video files. You would need another way to read the video to determine when the movie completed.

You could put your video files (flv or mp4) into a swf or load them from a swf and that would work. The .swf could communicate with the browser to tell it to close. 

Rebecca Rice

David - thanks and am glad this question is useful to others. I've never "added code to a frame in Flash" but can hopefully figure it out and ask someone in my IT dept if needed. I notice you mentioned this code is executed from within an .swf file. I've been exporting my .fbr files (after using BB Flashback software to record my software demonstrations - another helpful tip I picked up from these forums!) into .flv to insert into my Articulate modules. Do I now need to export my .fbr files into .swf for this "auto close of the new broswer window" to work? Thanks again.

David Anderson

Hi Rebecca - I haven't used BB Flashback but it appears to be a video format. What you need to be able to do is insert javascript into either the .swf file or the html file. Inserting into the .swf file is easy because Flash .swf files created in Flash will enable you to drop code at the end of the timeline. You could also use a more advanced player that "wraps" around your video file and "detects" when the video file has completed and then execute the script.

I don't know of any way to add code directly to a video file... I think it needs to be added to some type of wrapper that "reads" the video file and knows when the file is finished.

Do you have any option for entering javascript type code into your BB Flashback authoring tool?