JavaScript

How can I call a function written by JavaScript on the page ?

Andrew
andrewyuAsked:
Who is Participating?
 
SuperMarioConnect With a Mentor Commented:
use FSCommand, like so:

Step 1) your JavaScript.

function myMovieName_DoFSCommand(command, args)
{
   if(command == "DoFunction")
      DoFunction(args);
}

Step 2) your Flash.

in the Actions tab of the frame or button you want to manipulate, choose FSCommand from the plus drop down menu.

Fill in DoFunction for the command box and args for the argument.

So now your JavaScript will look like this:

<HTML>
<HEAD>
<TITLE>FS Command Test</TITLE>
<SCRIPT>
function DoFunction(var str)
{
   alert(str);
}
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT>
function myMovieName_DoFSCommand(command, args)
{
   if(command == "DoFunction")
      DoFunction(args);
}
</SCRIPT>

<!-- Flash code
<OBJECT blah blah blah>
<PARAM NAME=name VALUE=value>
</OBJECT>
<EMBED blah blah>
</EMBED>
</BODY>
</HTML>

and the Actions tab of the button or frame you want to use to call the JavaScript will look like this:

FSCommand("DoFunction", "My Message Here")

That should do it!
I hope this helps!
-Dan

0
 
andrewyuAuthor Commented:
Does myMovieName mean the filename of the swf ?

Andrew
0
 
SuperMarioCommented:
Yup =)

Just the filename of the swf.

If it doesn't work correctly, you need to do this when you export / publish:

Make sure to choose "Flash with FSCommand" from the types box in the publish dialog.

Glad to help!

-Dan
0
 
andrewyuAuthor Commented:
Thank you very much !

Andrew
0
All Courses

From novice to tech pro — start learning today.