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

5 most recent
Flash button as Flex icon
Tree menu
Flash Spell Checker
Flash Remoting Library
MX 2004 Chart/Poll
Articles