I want to show and hide the browser’s scrollbar depending on the height of a section within a Flash movie. I’m trying to use ExternalInterface, but it is not currently working for me. The Javascript works fine (I’ve tested it with HTML and can resize the Flash <div> correctly), but when I try to call it from Flash nothing happens.
Here’s my AS:
Stage.scaleMode = "noScale";
Stage.align = "TL";
Stage.addListener(this);
import flash.external.ExternalInterface;
_global.setHeight = function (h) {
if (ExternalInterface.available) {
ExternalInterface.call("resizeFlash", h);
}
block._height = h;
}
Here’s the Javascript & HTML:
<html>
<head>
<title></title>
<meta NAME="DESCRIPTION" CONTENT="">
<meta NAME="KEYWORDS" CONTENT="">
<meta name="AUTHOR" content="">
<meta NAME="revisit-after" CONTENT="5 days">
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<noscript></noscript>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
function resizeFlash( h ) {
if (h < 400){
document.getElementById("flash_root").style.height = 100 + "%";
} else {
document.getElementById("flash_root").style.height = h;
}
}
</script>
</head>
<body onLoad="javascript:resizeFlash('0');" bgcolor="#ffffff" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginheight="0" marginwidth="0">
<a href="javascript:resizeFlash('2000');">Click</a> <a href="javascript:resizeFlash('300');">Click2</a>
<div id="flash_root">
<div id="no_flash">You need <a href="http://www.adobe.com/go/getflashplayer" target="_blank">Flash</a> in order to view this content correctly.</div>
</div>
<script type="text/javascript">
// <![CDATA[
var fo = new SWFObject("test.swf", "root", "100%", "100%", "9");
fo.addParam("bgcolor","ffffff");
fo.addParam("salign","t");
fo.addParam("menu", "false");
fo.addParam("scale", "noscale");
fo.addParam("quality", "best");
fo.addParam("allowFullScreen", "true");
fo.addParam("allowScriptAccess", "sameDomain");
fo.addVariable("cache", "2");
fo.write("flash_root");
// ]]>
</script>
</body>
</html>
Anyone have any ideas on what might be going wrong? I feel like I’m just missing one piece of the puzzle in my code.