Main Page


on(release) {
fscommand(“send_message”, “the message”);
In order for JavaScript to handle this command, a special function must be defined. This function must
begin with the name (or ID) of the Flash movie object and be followed by
, such as the
function ExampleMovie_DoFSCommand(sCommand, vArgument) {
The function always accepts two arguments, the command and an argument. The command is always a
string, but the argument may be any primitive type. All calls to
are routed to this func-
tion, so, by providing different commands, you can determine what action should be taken with
JavaScript. For example:
function ExampleMovie_DoFSCommand(sCommand, vArgument) {
switch(sCommand) {
case “change_color”:
//change the color of something
case “change_height”:
//change the height of something
When using any browser other than Internet Explorer, this function is called when
is exe-
cuted. For Internet Explorer, another function is needed.
For reasons unknown, the Flash Player routes
calls in Internet Explorer to VBScript, not
JavaScript. VBScript is an IE-only technology that allows developers to use Visual Basic code to script
Web pages. Originally intended to compete with JavaScript, VBScript never gained the popularity or
support from other browsers that would have enabled it to be a true rival. Instead, it was remanded to
niche developers working on IE-only solutions.
In order to avoid writing a lot of VBScript, you can just write a simple function that passes the command
and the argument back to the JavaScript function. This code must be enclosed in its own
ment with the language attribute set to
. The VBScript function takes the same form as the
JavaScript function, although it ends with
instead of
<script language=”VBScript”>
Sub ExampleMovie_FSCommand(ByVal sCommand, ByVal vArgument)
call ExampleMovie_DoFSCommand(sCommand, vArgument)
end sub
Interacting with Plugins
21_579088 ch18.qxd 3/28/05 11:43 AM Page 557

JavaScript EditorFree JavaScript Editor     Ajax Editor