I'm using this code to play a swf with onclick command for an image. On the first click, I receive "flashMovie.Play is not a function" error. On the second click it works, and every time afterwards. Is this a conflict with the order of execution with other elements in the page? What is happening on the first click that makes the second click work properly? (this works in IE but not firefox)
Would putting some sort of timing delay on this possibly help? Any suggestions as to how I could try that?
<script language="JavaScript">
function getFlashMovieObject(movieName)
{
if (window.document[movieName])
{
return window.document[movieName];
}
if (navigator.appName.indexOf("Microsoft Internet")==-1)
{
if (document.embeds && document.embeds[movieName])
return document.embeds[movieName];
}
else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
{
return document.getElementById(movieName);
}
}
function PlayFlashMovie(name)
{
var flashMovie=getFlashMovieObject(name);
flashMovie.Play();
}
</script>