Now, you'll create a unique identifier with the JavaScript Date object.
The FlashProxy class expects this unique identifier as the first parameter and
must use it to create a connection between itself and the methods in your Flash
file. The second parameter is the relative path to the
JavaScriptFlashGateway.swf. In the sample, I added a highlightItem() method to
JavaScript to be used by Flash, which will change the background color in the
HTML for a particular lender's div.

In the body of your page, you can use the shortcut provided by the FlashTag
object to create your Flash tags. To use it, first instantiate the FlashTag
object and pass it these four parameters:

The path to your Flash file

The width of your Flash file

The height of your Flash file

The version of Flash that you are targeting

Set the Flashvars() method of the FlashTag object to the unique id that you
created with the Date object. The id will be used through flashvars by your
Flash file as a LocalConnection id with the JavaScriptFlashGateway.swf that you
just added. The final line writes the Flash tags to your file.

To make calls to Flash from JavaScript, you need to use the FlashProxy
object. The parameters to pass the FlashProxy object are a method name that you
will define in Flash and any number of parameters that you want to accept in
your Flash method. In my example, I use two—the name of the lender and the
lender's rate.

javascript:flashProxy.call('addItem', '"+ name +"', "+ rate +");

NOTE

There is a bug that I recently reported to the open
source Flash team. The Integration Kit does not allow multiple consecutive
method calls from JavaScript to Flash because it only successfully makes the
last call, ignoring the others. To work around this bug, you can create a method
in Flash that accepts arrays and loops through the arrays to call another method
on each item. You will see a sample of how to create this method in the
JavaScript to Flash section of the article.