Javascript variable to flash

[LEFT]Hi

I’m having some problems sending a javascript variable to flash.

The problem is between the:

“setPage(newPage)” function

throughout the:

“<div id=“flashDiv” sty…”

to the:

“document.write(’<object data=“main.swf” width=“100%” height=“100%” type=“application/x-shockwave-flash” id=“flash”>’);”

  • take a look at the .html code below:
<html>
<head>
<title>Macro-Design</title>
<script type="text/javascript" src="flash_resize.js"></script>
<script language="JavaScript">

function setPage(newPage) {
    if (window.document.getElementById("flashDiv").flash) {
        window.document.getElementById("flashDiv").flash.SetVariable("page", newPage);

    }
}</script>
</head>
<body bgcolor="#FFFFFF">
<div align="center">

    <div id="flashDiv" style="width:400px; height:300px;">

        <script type="text/javascript" language="JavaScript">
            e = canResizeFlash();

            document.write('<object data="main.swf" width="100%" height="100%" type="application/x-shockwave-flash" id="flash">');

            document.write('<param name="movie" value="resize.swf" />');
            document.write('<param name="FlashVars" value="allowResize='+e+'" />');
            document.write('</object>');
        </script>
        <noscript>Javascript must be enabled to view Flash movie</noscript>
    </div>
</div>
</body>
</html>

I think it’s in the “window.document.getElementById(“flashDiv”).flash.SetVariable(“page”, newPage);” something goes wrong. I suspecting the “getElementById(“flashDiv”)” is the problem, but I have not idea on how to solve it…

Have a nice day :sure:

[/LEFT]