Tutorial details:
Written by: AshzFall / http://www.ashzfall.com/
Difficulty Level: Intermediate
Requirements: Flash 5 The AF FS Command JavaScript Library
Using JavaScript, it is possible to communicate with and control a Flash movie hosted in an HTML page. It is also possible to have the same level of control and communication with multiple Flash movies in the same document or across windows and frames.

This library contains functions for the standard methods of interaction with Flash movies (as documented on the Flash Methods page at Macromedia) and additional functions for the time and date, cookie control, creating windows, and for interacting with site visitors via message boxes.

With this library, you can create multiple movie references. This means that you will be able to control more than one Flash movie. The references you create can be to movies in the same document or in different frames or windows. And, making a function enact upon a movie is as simple as sending the number you used to create the reference as a part of the current function's arguments.

The functions in this library may be called either from FS Commands inside of a Flash movie, from JavaScript calls from within HTML, or from Get URL JavaScript calls from inside of a Flash movie.

These methods will not work with Internet Explorer on Macs. This lack of functionality is a brower issue with communication with plugins and cannot be resolved by anyone except MicroSoft.

The templates were updated on March 28, 2000. Posted templates no longer include second object and embed pair from the testing environment. No additional functions added.

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

For more detailed information on the library, see the reference area.

To get the library, see the download area.

As of this posting, the library has been tested only on Windows. If you are a Mac or Windows user and encounter any difficulties with the examples, please contact me with a bug report.

In the future, more functions will be added to this library. If you have an idea for a function you would like to see added, please contact me with your idea. (To be added to the library, a function must have some general appeal, and not all suggestions will be added.)

Talk to Yourself

Communicate between 2 frames
Communicate between main browser and a new window (pop up)
Communicate between 2 new windows (2 popups)
(Note on 2 popup version: look at the source of the loading window as well as this sets the f1 values.)

This is a pseudo chat client that demonstrates communicating between two swf files in separate frames or windows. You simply input text into the text box on one chat box and hit the 'send' button to transfer the text to the other chat box.

These examples are intended for people with some experience with JavaScript who would like to enable FS Command methods across frames and windows without use of the AF FS Command JavaScript Library.

In all of the examples available from the bottom of this page, the movie name in the embed and object tags is 'fscom'. The text box inside the fscom swf movie is labeled 'chatbox'. The FSCommand is set to FS Command ("send", /:chatbox) from the release mouse event of the send button.

The f1 variable in each script is either preset in the html or set by a script function. The f1 variable sets the location (frame or window) for the opposite instance of the 'talk to yourself' flash file (the one you are sending the information to). The 'fscom1' variable sets the object reference for the swf.

The script is not commented at this time. In general, it works like this:
1) A page with a swf is loaded.
2) The onLoad event in the body tag is used to call a function that sets fscom1 (the object reference).
(Note: fscom1 must also be global to the page so that it can be found by other pages. This is done by initially placing it outside of any function and declaring it as having a null value.)
3)The f1 location reference is either already set or is set by the opening document.

So, to set the variables in a swf in another page, you need to refer to it as f1.fscom1.setVariable("varName", "value"). Which translates as Window and Frame Reference.Embedded Object Reference.Set Variable Function

Feel free to view the source and use it as you please. I worked with the automatically generated Flash4 page (from the template for including FSCommands) so that you can easily compare it to an original and see what was added and changed.

I hope this helps.
(And, that you have fun talking to yourself.)