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
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
Shake the previously opened Movie
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
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|
Rating: 9 Votes: 149
|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 the files used in this tutorial.|
|Download (0 kb)|
|More help? Search our boards for quick answers!|