First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: Jeffrey F. Hill | Website: http://www.flash-db.com

Manipulating, Moving, Resizing, Scrolling, and Animated effects for the window Once opened

The following reference provides ways to control you popup window once opened. You can either place the code on buttons that control the popup or on frame actions that will manipulate the popup window at certain time's when the movie is playing. We'll start off with some simple functions then move onto some more complex ones. You can also combine these with the previous section and have the various affects occur when the popup is loaded.

Move previously opened Window

on (release, rollOver) {
getURL ("javascript:NewWindow.moveBy(30,0); NewWindow.focus(); void(0);");
}

The above code will move a window you previously opened 30 pixels to the right (horizontal). The main code that controls this is NewWindow.moveBy(30,0); The (30,0) represents the X and Y coordinates you want to move the window to, respectively. The NewWindow.focus(); is also used to bring the window to the front of the browser each time you move it. If this part was left out the window would still move, but it would be behind the parent window so you would not see it move. Both on (release, rollOver) where used in this example - meaning that if a person rolls over the button that this code is located on the popup button will move 30 pixels to the right.

You can use the same basic method to Scroll or Resize a popup window as well. The only thing that would change would be the moveBy(30,0) part. To scroll this would be scrollBy(30,0) and to resize it would be resizeBy(30,0). The scrollBy one is probably one of the most interesting and useful because you can scroll to different parts of the page you opened with the popup window - all controlled by the parent movie. Also the (30,0) are just arbitrary numbers - you can use any numbers their that you want - for example moveBy(300,230) would cause the movie to move 300 px to the right and down 230 px.

One of the most important parts of the above code is that you use the same window object to reference the popup that you originally created the popup window with. In this case that would be 'NewWindow'. It should be noted that you can use any name for the window object as you want - as long as you keep it consistant.

Close previously Opened window

on (release) {
getURL ("javascript:NewWindow.close(); void(0);");
}

This just closes the window that you originally opened from a button in the parent Flash movie. Again it's important to keep the window object variable names the same. To close a window from itself (meaning the button is located in the same window you are closing) you can just leave out the 'NewWindow' variable name and use getURL ("javascript:close(); void(0);");

Shake the previously opened Movie

on (release, rollOver) {
getURL ("javascript:NewWindow.focus(); for (i=10; i>0; i--) 
{ for (j=6; j>0; j--) { NewWindow.moveBy(0,i); NewWindow.moveBy(i,0);
NewWindow.moveBy(0,-i); NewWindow.moveBy(-i,0); }} void(0);");
}

Probably the best effect. This effect shakes the popup window for specific intervals and shakeness (couldn't think of better word).

The first thing that we do is bring the popup window to the front of the browser, like always with NewWindow.focus(); Then we use two 'for' loops to move the window back and forth and up and down really fast. You can change the settings by changing the values for i and j.

Animated Move, Resize, and Scroll

on (release, rollOver) {
getURL ("javascript:NewWindow.focus(); for (j=150; j>0; j--) {
NewWindow.moveBy(2,1.33333333333333); } void(0);");
}

The above function shows how to create an animated Moving window. This will move your popup window across your screen. Like always we use the focus(); command to move the window to the front before we move it. Then we use a 'for' loop to move the window across the screen in small increments. In this case the variable j indicates how many times it will incrementally move. By increasing j to say j=300 will increase the smoothness of the move creating smaller increments. Watch out though if you make j to large you'll freeze up your computer and get stuck in an infinite loop.

This is basically the same code used for the Animated Resize and Animated Scroll. To change this over to Animated Scroll or Animated Resize you would for example change the NewWindow.moveBy( portion to NewWindow.scrollBy(.

» 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!

Comments

  • 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.