JavaScript

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

Andrew
andrewyuAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SuperMarioCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.