Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flash/JavaScript communication problem ... scope?

Status
Not open for further replies.

andrewbadera

Programmer
Jan 27, 2002
43
US
JavaScript SetVariable and GetVariable seem to work fine, but ActionScript within the Flash object doesn't seem to be seeing the variables update ...


object code:
Code:
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
 codebase="[URL unfurl="true"]http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"[/URL]
 WIDTH="305" HEIGHT="100" id="test" ALIGN="">
 <PARAM NAME=movie VALUE="test.swf">
 <PARAM NAME=quality VALUE=high>
 <PARAM NAME=autostart VALUE=true>
 <PARAM NAME=bgcolor VALUE=#FFFFFF>
	<EMBED src="test.swf" quality=high bgcolor=#FFFFFF  WIDTH="305" HEIGHT="100" NAME="test" ALIGN=""
 TYPE="application/x-shockwave-flash" PLUGINSPAGE="[URL unfurl="true"]http://www.macromedia.com/go/getflashplayer"[/URL] SWFLIVECONNECT="true"></EMBED>
</OBJECT>

JavaScript:
Code:
function test_doFSCommand(command, args) { 
//ie window.testObject nn window.document.testObject
	var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
	var testObj = InternetExplorer ? test : document.test;

	//alert("fscommand - " + command + ": " + args);
	if ( command=="show" ) { 
		alert(args);
	} else if (command == "setlocal") {
		alert("javascript - SetVariable(varLocal, " + args + ")");
		testObj.SetVariable("varLocal", args);
		alert("javascript - GetVariable(varLocal): " + testObj.GetVariable("varLocal"));
	} else if (command == "setglobal") {
		alert("javascript - SetVariable(varGlobal, " + args + ")");
		testObj.SetVariable("varGlobal", args);
		alert("javascript - GetVariable(varGlobal): " + testObj.GetVariable("varGlobal"));
	}
 }

ActionScript:
Code:
var varLocal = -1;
fscommand("show", "flash - varLocal: " + varLocal);
fscommand("setlocal", 1);
fscommand("show", "flash - varLocal: " + varLocal);

_global.varGlobal = -2;
fscommand("show", "flash - varGlobal: " + varGlobal);
fscommand("setglobal", 2);
fscommand("show", "flash - varGlobal: " + varGlobal);

stop();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top