[thelist] Flash calling Javascript

Norman Beresford n.beresford at anansi.co.uk
Wed Aug 10 04:05:56 CDT 2005


Hi all

I've got a real pita Flash problem at the moment and I was hoping
someone on here could point me in the direction of solving it.

I have an HTML page, which has a div containing a Flash movie.  There's
a couple of javascript functions on the page which either resize the div
so that it disappears, or simply sets it's visibility to false.  The
Flash movie runs and when it's finished running it's supposed to call
the javascript function so that it disappears.  As a test I've added a
button to the page which calls either function.

The problem is quite simple.  In Firefox clicking the button will make
the movie disappear, and letting the Flash movie run will make it
disappear.  In IE 6.0 clicking the button will make the movie disappear,
but if I just let the movie run it won't.  It seems that the movie won't
call the function in IE.  I've tried using both
getURL("javascript:ResizeFlashMovie()"); and
fscommand(ResizeFlashMovie); and while both work in FF neither works in
IE.

Does anyone have any pointers?  Various bits of code follow.

Norman

The HTML for the div and flash movie

<div id="flashDiv" style="width:500px; height:500px">
			<OBJECT id="rip_final03"
codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflas
h.cab#version=6,0,0,0"
				height="100%" width="100%"
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" VIEWASTEXT>
				<PARAM NAME="_cx" VALUE="7673">
				<PARAM NAME="_cy" VALUE="9260">
				<PARAM NAME="FlashVars" VALUE="">
				<PARAM NAME="Movie"
VALUE="rip_final03.swf">
				<PARAM NAME="Src"
VALUE="rip_final03.swf">
				<PARAM NAME="WMode" VALUE="Window">
				<PARAM NAME="Play" VALUE="0">
				<PARAM NAME="Loop" VALUE="-1">
				<PARAM NAME="Quality" VALUE="High">
				<PARAM NAME="SAlign" VALUE="">
				<PARAM NAME="Menu" VALUE="-1">
				<PARAM NAME="Base" VALUE="">
				<PARAM NAME="AllowScriptAccess"
VALUE="always">
				<PARAM NAME="Scale" VALUE="ShowAll">
				<PARAM NAME="DeviceFont" VALUE="0">
				<PARAM NAME="EmbedMovie" VALUE="0">
				<PARAM NAME="BGColor" VALUE="99FF00">
				<PARAM NAME="SWRemote" VALUE="">
				<PARAM NAME="MovieData" VALUE="">
				<PARAM NAME="SeamlessTabbing" VALUE="1">
				<EMBED src="rip_final03.swf"
quality="high" bgcolor="#99FF00" WIDTH="100%" HEIGHT="100%"
NAME="rip_final03" ALIGN="" TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"
swLiveConnect="true">
				</EMBED>
			</OBJECT>		
		</div>

The javascript functions:

function rip_final03_DoFSCommand(strCommand, strArgs)
		{
			alert('Fired');
			hideDiv('flashDiv');
		}
		
		function hideDiv(pass) {
			var divs = document.getElementsByTagName('div');
			for(i=0;i<divs.length;i++){
				if(divs[i].id.match(pass)){//if they are
'see' divs
					if (document.getElementById) //
DOM3 = IE5, NS6
	
divs[i].style.visibility="hidden";// show/hide
					else
						if (document.layers) //
Netscape 4
	
document.layers[divs[i]].display = 'hidden';
						else // IE 4
	
document.all.hideShow.divs[i].visibility = 'hidden';
				}
			}
		}
		
		
		function ResizeFlashMovie()
		{
			hideDiv('flashDiv');
		}
		
		function setFlashWidth(divid, newW){
			document.getElementById(divid).style.width =
newW+"px";
		}
		
		function setFlashHeight(divid, newH){
			document.getElementById(divid).style.height =
newH+"px";		
		}
		
		function setFlashSize(divid, newW, newH){
			setFlashWidth(divid, newW);
			setFlashHeight(divid, newH);
			}


More information about the thelist mailing list