The AF FS Command JavaScript Library Movie Reference Information

This is a continuation of the Movie Reference Information page and requires that you have read and understood that page.

Working with frames

When working with frames, you must use the setFrameRef function to create the movie reference(s). If the movie is in a named DIV or LAYER tag, you must use setLayerFrameRef function.

The name of the frame that is required by these functions is set in the FRAME tag NAME attribute.
<FRAME SRC="mypage.html" NAME="myFrame">

Each frame document that has a movie that sends out FS Commands must at least be created using the standard FS Command template included in Flash. One of the frames will have to hold the entire script for all of the other frames and movies to use.

It is possible to have the full script in more than one frame, but the movie references created in one frame will not be directly available to the function calls in the other frames.

In most circumstances, it is best to host the script in one frame and to direct all function calls to the script in that frame. The method for doing this depends on whether you are using FS Commands or JavaScript (in HTML or via the Flash Get URL).

For FS Command calls to that script frame, you will need to add the following line to the area within the movieName_DoFSCommand function reserved for placing your script actions:
windowRef.frames['frameName'].doComs(command,args);

windowRef must be either top or parent.
top.frames['frameName'].doComs(command,args);
parent.frames['frameName'].doComs(command,args);

windowRef refers to the document window that spawned the frameset (the page that contains the FRAMESET tags). Unless you have nested frames, top and parent are the same and refer to the uppermost document window. Nested frames are when a document in a frame also has a FRAMESET. When called from a frame created by the nested frameset, top still refers to the uppermost document window, but parent now refers only to the frame that spawned the nested frame.

frameName must be replaced with the actual name of the frame that holds the script. The frameName must be enclosed in single quotes.

Making this change to the generated page, will redirect all calls from FS Command to the frame with the JavaScript library.

If you have the script only in one frame and need to make calls to the script directly in JavaScript or by using JavaScript in the Get URL action in Flash, you will just need to add the same format of a window and frame reference before the function call as was shown in the FS Command example above.

Get URL ("top.frames['myFrame'].playMovie(2)")
will call the script in the frame named myFrame to play the movie with the movie reference of 2.

The tricky part
Movies in a frame must exist before they can have a reference set to them in JavaScript. This means that it is better to have each movie or onLoad event script create the movie reference for the movie(s) on that page. The calls should be redirected to the frame with the script using the methods indicated above and only after it is known that the frame with the library script in it exists. There is a variable in the library named libLoad that indicates when the entire script has been read into the browser. When the script has been read, libLoad is true (1) otherwise libLoad is false (0).

Here is an example of using libLoad to create movie references in a frame that does not house the script library:
function myLoader()
{
if (top.frames['myFrame0'].libLoad)
{
top.frames['myFrame0'].setFrameRef('myFrame1','myMovie1',5);
top.frames['myFrame0'].setFrameRef('myFrame1','myMovie2',6);
}
else {myLoader();}
}
This function is called from the onLoad event of the HTML page in the myFrame1 frame and will create references to the two movies on this page in the script in the frame named myFrame0. If the script in myFrame0 has not finished loading, it will continue to call this function until the loading is completed.

Parents Only
The setFrameRef and setLayerFrameRef functions use the parent window reference for the frame that holds the script. This means that you will not be able to create a reference to a frame in the top frameset if the frame that hold the script is a nested frame.

These functions also do not allow you to create a reference to a nested frame from a frame that is outside of the nested frameset.

All this simply means is that the use of nested frames will require some additional scripting. The exact nature of this additional scripting is beyond the scope of this informational document. For more information, you should look at a JavaScript reference on working with frames.

Setting Movie References in Multiple Windows

To get a quick view of some of the things that are possible with this library, see the examples.

To get the library, see the download area.


Examples Download Reference

Copyright©2000, AshzFall. All Rights Reserved.
Macromedia and Flash are trademarks of Macromedia, Inc.