PDA

View Full Version : Send variables from javascript to flash 8


edurs2000
01-28-2006, 06:04 PM
Hi

I need a webpage with buttons in javascript with diferents variables.
Each button pressed send names of videos to flash mediaplayback plays.


I have a code that you can send a variable from javascript to flash video player..
I try to change this javascript for add more buttons to change the videos in flash without sucess :confused:



Html with javascript

<HTML>
<HEAD>
<TITLE>javascript_to_flash</TITLE>
</HEAD>
<SCRIPT LANGUAGE=JavaScript>
<!--

function doPassVarBT(args){
var videoFlash = args.value;
window.document.myFlash.SetVariable("myVar", videoFlash);

}

//-->
</SCRIPT>
<BODY bgcolor="#FFFFFF">

<form name="form1" action="#">
<input type="button" name="video" value="video1.flv" onClick="doPassVarBT(this);">
</form>
<p>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
width=350 height=300 id="myFlash">
<param name=movie value="javascript_to_flash.swf">
<param name=quality value=high>
<embed src="javascript_to_flash.swf" quality=high width=350 height=300 type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" name="myFlash" swLiveConnect="true">
</embed>
</object>
</BODY>
</HTML>




Actionscript:

1 Frame:
if (myVar.length != undefined) {
gotoAndStop(3);
}

2 Frame:
gotoAndPlay(1);

3 Frame:
playback.contentPath=myVar;

(playback instance of Mediaplayback)