Archive
This is an archived tutorial about Flash. It's kept for history and may reference outdated tech.
TL;DR
You can open a pop-up window centered on the screen by having a Flash button call getURL with a JavaScript Launch function, passing the page URL, width, and height. After publishing, paste the JavaScript above the body tag of the HTML file Flash generated, and the function centers the window for you.
- The button with the instance name btn_Up uses an onRelease handler to call Launch with a URL, 400, and 300.
- Re-publishing from Flash overwrites the HTML file, so you'll need to paste the JavaScript back in each time.
- Leave the width, height, top, and left properties in the script alone; they use your link's arguments, and changing them can break the centering.
- Flash security settings might stop the pop-up from working when you test it locally on your computer.
Despite not being user-friendly, pop-up windows are very popular ways of displaying content. With pop-up windows, you have the added advantage of being able to hide the unnecessary browser GUI features such as the toolbars, address bar, status bar, etc. that might make viewing your animation less pleasant.
In this tutorial, I will explain how to create a new pop-up window that is centered perfectly on your screen. Click on the GO button in the following animation for an example of what you can create:
[ click the GO button to launch a pop-up ]
When you pressed the GO button in the example above, you should have seen a new window appear in the center of your screen. Let's get this working in three easy steps.
Step 1In Flash, create a button. Give it the instance name btn_Up. Copy and paste the following code into a frame on your timeline:
btn_Up.onRelease = function() {
getURL("javascript:Launch('http://www.kirupa.com/sotw/archive.htm', 400, 300)");
};
Step 2Publish your Flash movie by going to File | Publish. When you Publish, the directory containing your movie will now have your FLA, the SWF, and the HTML file corresponding to the SWF:

[ files produced after you Publish your FLA ]
Step 3Find the HTML file produced by Flash after you published your movie, open that file in a HTML editor, and copy and paste the following JavaScript code above the <body> tag of your HTML code:
If you open your HTML file in a browser, you should see your Flash animation. Click on the button and the pop-up window will appear.
Note
If your JavaScript code is on the HTML page generated by Flash, and if you were to re-publish your animation in Flash, you will have to manually re-paste the JavaScript code into your HTML document.When you publish, Flash overwrites any old SWF's and HTML files with the new version.
Note
For width, height, top, and left properties, you should leave them unaltered. They use the arguments from your link code, and making any modifications could cause your centered pop-up window to not work as advertised.
ConclusionWell, you are finished with this tutorial. This code was based on the code I used in the pop-up window tutorial written many years ago. I have provided the source file, swf, and HTML files used for the example animation:
Because of security settings in Flash, you might not be able to test the pop-up locally on your computer.
Before you go, here are a few things you can do:
-
Keep reading
Read the next article in the series, Apply and Animate Filter Effects, or check out some related content:
-
Ask a question
Stuck on something, or curious about a detail we skipped? Ask on the forums, and we’ll help you out.
Just a final word before we wrap up. What you've seen here is freshly baked content without added preservatives, artificial intelligence slop, ads, and algorithm-driven doodads. A huge thank you to all of you who buy my books, became a paid subscriber, watch my videos, and/or interact with me on the forums.
Your support keeps this site going! 😇

Just a final word before we wrap up. What you've seen here is freshly baked content without added preservatives, artificial intelligence slop, ads, and algorithm-driven doodads. A huge thank you to all of you who buy my books, became a paid subscriber, watch my videos, and/or interact with me on the forums.
Your support keeps this site going! 😇

