| home / tutorials
/ FS Command JavaScript Library / Working with
windows Tutorial details: Written by: AshzFall / http://www.ashzfall.com/ Difficulty Level: Intermediate Requirements: Flash 5 Working with windows In order to create a reference to a movie in another window, the window must have been created using the popupMaker function. As with movie references, window references are stored in an array and the window number used to create the window via popupMaker should not be used to create additional windows. The window number used to create the window via popupMaker is the number that must be sent as the window number in all functions that create a movie reference for a movie in another window. Do not use 0 as the window number when creating a window via popupMaker Setting References If there are frames in any of the other windows, you must use either setWindowFrameRef or setLayerWindowFrameRef to create the movie references for movies in the frames. It is also strongly recommended that you read Setting Movie References in Multiple Frames. To allow commands to be sent back and forth between windows, at least one document in each window must have the script library loaded into it. The following examples and information pertain only to windows that do not involve frames. To work with a combination of frames and windows, you will need to fully understand this document and Setting Movie References in Multiple Frames. You will need to combine the techniques in both documents together in a manner that best suits your exact situation. In this example, there is the main window (the one that the user surfed to) and a window created with popupMaker with the window reference number of 1. To set a movie reference inthe main window to a movie in the window with the reference number of 1, you would send 1 as the window number in the movie reference creation function. Do not confuse the movie reference number with the window reference number. Although the two reference numbers can be the same, they are referring to two different arrays. The window array holds only the references to the actual windows and not any of their content. The movie array holds a direct reference to an individual movie that can be in the same document or a different frame or window. Back to the example playMovie(12) To make a reference to a movie in the main movie from the popup window,
use the window reference number of 0 to create the movie reference. So, calling playMovie(12) in the popup window will now play a movie named myMovie1 in the main window, and calling playMovie(12) from the main movie will still play the movie named myMovie0 in the popup. The tricky part The most simple method for doing this would be to create a function similar to the onload event covered in the Movie Reference Information page. The function would reside in the script in the main window, but be called via the onLoad event of the popup window. Still assuming that the popup window was created with the window reference
of 1, and that there are no frames involved, the script in the main window
would look something like this: This onLoad event action will call the function in the main window and create the three movie references in the main window. These movie references will not exist to the popup window. If you need to create one or more movie references in the popup window
as well as in the main window, you will need to create a function to handle
the onLoad event of the popup window document. function myLoader1()
As you can see in this example, to make a call to myMovie6 from the main window, you would use the movie reference number of 7. But, to make a call to this same movie from the popup window, you would use the movie reference number of 2. To make a call to myMovie1 from within the main window, the reference number would be 0. To make a call to the same movie from the popup, the reference would be 3. |
||