PDA

View Full Version : Javascript calling Actionscript


dedwardsnew
07-17-2003, 05:59 PM
How can I get Javascript (in an Html page) to call an actionscript function in a movie on that same page?

I know this will require two main connection points:
1) How the Flash movie is named. I make every effort to name the movie "Test".

I use this code:


<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"
WIDTH=100% HEIGHT=100% ID="Test" NAME="Test">
<PARAM NAME=movie VALUE="Test.swf">
<PARAM NAME=menu VALUE=false>
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED src="Test.swf" menu=false quality=high bgcolor=#FFFFFF WIDTH=100% HEIGHT=100% ID="Test" NAME="Test" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>
</OBJECT>
<

--------------------------------------
2) How the Javascript references the Flash movie. I am trying to call an Actionscript function in my movie called OnJavascript()
I use this code, but it doesnt work:


if (navigator.appName.indexOf("Microsoft") !=-1)
{
window.Test.OnJavascript("TestMs");
}
else
{
document.Test.OnJavascript("TestNs");
}


Your help is appreciated!

webguy
07-18-2003, 12:09 PM
I haven't tried this, only heard it here on the boards. You can pass a variable to your movie through the embed code. Then use evaluate that variable to execute your function.

[embed src="test.swf?dofunction=true"]


if(_level0.dofunction == true) {
calledFunction();
}


web