We help IT Professionals succeed at work.
Get Started

Flash/Javascript/Firefox gives error "SetVariable is not a function"

1,822 Views
Last Modified: 2013-12-07
Trying to set a variable in a flash movie via javascript. Works in IE, not in FF. FF says "SetVariable is not a function". Here's the code, have fun:

        <script type="text/javascript"><!-- Hide
            function getFlashMovieObject(movieName)
            {
                if(document.embeds[movieName])
                    return document.embeds[movieName];
                if(window.document[movieName])
                    return window.document[movieName];
                if(window[movieName])
                    return window[movieName];
                if(document[movieName])
                    return document[movieName];

                return null;
            }

            function moveMovie(el, ev)
            {
                var ev = ev || window.event;
                var mov = getFlashMovieObject('bseFlvPlayer');
           
                if (ev.pageX == null)
                {
                  // IE case
                  var d= (document.documentElement && document.documentElement.scrollLeft != null) ? document.documentElement : document.body;
                  docX= d.scrollLeft;
                  docY= d.scrollTop;
                }
                else
                {
                  // all other browsers
                  docX= window.pageXOffset;
                  docY= window.pageYOffset;
                }

                if( el.style.position != "absolute" )
                {
                    el.style.position = "absolute";
                    el.style.top = docY+"px";
                    el.style.left = docX+"px";
                    mov.style.position = "absolute";
                    mov.style.width = "65%";
                    mov.style.height = "65%";
                    mov.style.top = (el.offsetHeight - mov.offsetHeight) / 2;
                    mov.style.left = (el.offsetWidth - mov.offsetWidth) / 2;
                    document.getElementById('restoreButton').style.left = mov.offsetLeft;
                    document.getElementById('restoreButton').style.top = mov.offsetTop + mov.offsetHeight + 5;
                    document.getElementById('restoreButton').style.display = "block";
                    document.body.style.overflow = "hidden";
                }
               
                else
                {
                    el.style.top = 0;
                    el.style.left = 0;
                    el.style.position = "relative";
                    el.style.width = "100%";
                    el.style.height = "100%";
                    mov.style.position = "absolute";
                    mov.style.width = "100%";
                    mov.style.height = "100%";
                    mov.style.top = 0;
                    mov.style.left = 0;
                    document.getElementById('restoreButton').style.display = "none";
                    document.body.style.overflow = "auto";
                }
// ****** Error occurs on the next line only ******** //
                mov.SetVariable("vidHeight", mov.offsetHeight-19);
                mov.SetVariable("vidWidth", mov.offsetWidth);
                mov.SetVariable("resizeOnly", 1);
                mov.Play();
            }
             // End Hiding -->
            </script>

            <object id="bseFlvPlayer" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="<?=(int)$this->playerWidth?>" height="<?=(int)$this->playerHeight+19?>" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
                <param name="FlashVars" value="movHeight=<?=$this->videoH?>&movWidth=<?=$this->videoW?>&vidURL=<?="../{$this->videoDir}".$this->videoFile?>&previewURL=<?=$this->storeDir.$this->imageDir.$this->previewFile?>&vidWidth=<?=$this->playerWidth?>&vidHeight=<?=$this->playerHeight?>" />
                <param name="src" value="<?=$this->storeDir."includes/bsePlayer.swf"?>" />
                <param name="allowfullscreen" value="true" />
                <param name="wmode" value="transparent">
                <embed type="application/x-shockwave-flash" width="<?=(int)$this->playerWidth?>" height="<?=(int)$this->playerHeight+19?>" src="<?=$this->storeDir."includes/bsePlayer.swf"?>" allowfullscreen="true" FlashVars="vidURL=<?="../{$this->videoDir}".$this->videoFile?>&previewURL=<?=$this->storeDir.$this->imageDir.$this->previewFile?>&vidWidth=<?=$this->playerWidth?>&vidHeight=<?=$this->playerHeight?>" wmode="transparent" allowScriptAccess="always" swliveconnect="true" name="bseFlvPlayer">
                </embed>
            </object>
Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE