First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Jeffrey F. Hill | Website: http://www.flash-db.com

Adding Custom Functions and Effects to your popup window

Their is really no limit to the amount of effects you can add to the popup window your opening. I'll try to go over a few relevant examples and what makes them work. Then you can create your own or use the Auto-Code Generator. Some effects are not cross browser compatible and some may not work when opening pages outside of the domain where your movie is located.

Move window to new position 1000 milliseconds (1 second) after it loads

on (release) {
getURL ("javascript:NewWindow=window.open('ShowPopup.php','newWin','width=400,height=300,left=0,top=0,
toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No');  NewWindow.focus();
setTimeout('NewWindow.moveTo(200,300)',1000); void(0);");

The above script allows you to 'move' the window to a new location at a certain time after it opens. The setTimeout part controls the time delay (in milliseconds) to wait until that part of the code is activated. The NewWindow.moveTo(200, 300) part tells the window where to go, the (200,300) part is the same as the X and Y coordinates of where you would like your window to move to. It is important to note that we always reference the popup window by the object name we gave it in the first part of the script 'NewWindow'.

Display an Alert before window is opened then scroll to a specific point 3 seconds after it loads

on (release) {
getURL ("javascript:NewWindow=window.open('ShowPopup.php','newWin','width=400,height=300,left=0,top=0,
toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No');  alert('Flash Rules'); NewWindow.focus();
setTimeout('NewWindow.scroll(0,400)',3000); void(0);");

The above code will open a new window with the various properties as indicated. Then display an Alert box that contains the text 'Flash Rules' before the window opens. The alert('Flash Rules'); is the code that will activate the alert. Then we add the code setTimeout('NewWindow.scroll(0,400)',3000); to Scroll the window down by 400 px - the (0,400) part represents the X and Y coordinates you want to scroll by. The setTimeout part adds a delay to the scroll, in this case the delay time is 3000 milliseconds or 3 seconds, before the scroll happens. It can be important at times to add a delay because you can't scroll a page that has not loaded.

Open window, Resize it after 1 second, then Close it after 6 seconds

on (release) {
getURL ("javascript:NewWindow=window.open('ShowPopup.php','newWin','width=400,height=300,left=0,top=0,
toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No'); NewWindow.focus();
setTimeout('NewWindow.resizeTo(500,500)',1000);  setTimeout('NewWindow.close()',6000); void(0);");

The above code opens a popup window, the resizes it after 1 second to the new dimensions of (500,500) instead of 400 x 300. This is done by the code: setTimeout('NewWindow.resizeTo(500,500)',1000);. Then it is closed after 6 seconds by the code setTimeout('NewWindow.close()',6000);. The most important thing to notice about the delay close code is the NewWindow.close() This is the basic code that will close a popup window.

As you can see by now their is really no limit to the amount of effects that you can add. The main limitation is not with the JavaScript or Flash but with Browser compatibility. The resizeTo and scroll functions will not work with all browsers. You can get fairly creative by mixing and matching functions and portions of the code. The next section deals with manipulating and adding more effects to the Popup window you recently opened from the parent Flash movie.

» Level Intermediate

Added: 2002-01-09
Rating: 9 Votes: 149
(10 being the highest)
» Author
Jeffrey Hill is a freelance web developer from Boulder, Colorado. He specializes in creating and developing dynamic database driven Flash content and applications. Specialty's include SQL, PHP, Perl, and XML.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.