by kirupa |
28 January 2006
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 1
In Flash, create a button. Give it the instance name btn_Up. Copy and
paste the following code into a frame on your timeline:
Step 2
Publish 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 3
Find 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.
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.
In the next page, I will explain how to customize the pop-up
window.
Onwards to the
next page!
|