flashMovie.Play不是一个函数 [英] flashMovie.Play is not a function

查看:133
本文介绍了flashMovie.Play不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这段代码,用onclick命令播放一个图片。在第一次单击时,我收到flashMovie.Play不是一个函数错误。在第二次点击它的作品,每次以后。
这是否与页面中其他元素的执行顺序冲突?
第一次点击发生了什么,使第二次点击正常工作?
(这在IE浏览器,但不是Firefox的工程)



将这可能会有助于某种时间延迟?任何关于如何尝试的建议?

 < script language =JavaScript> 
函数getFlashMovieObject(movieName)
{
if(window.document [movieName])
{
return window.document [movieName];

$ b $ if(navigator.appName.indexOf(Microsoft Internet)== - 1)
{
if(document.embeds&& .embeds [movieName])
return document.embeds [movieName];

else if(navigator.appName.indexOf(Microsoft Internet)!= - 1)
{
return document.getElementById(movieName);



函数PlayFlashMovie(name)
{
var flashMovie = getFlashMovieObject(name);
flashMovie.Play();
}
< / script>


解决方案

被点击,那么你可能会遇到这个问题。我不认为任何一种具体的时间延迟是一个好主意,例如,如果你正在等待的话,那么最好是找出你正在等待的东西,然后执行正确的处理程序。

整个页面在执行之前加载,而不是延迟1秒,实现 document.onload 处理程序,如下所示:

  document.onload = function(){
//您的代码在这里
}

另外,您可以考虑使用 SWFObject ,因为它让你的生活在使用Flash和JavaScript方面变得简单。


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>

解决方案

If your flash movie isn't loaded before your button is clicked, then you might encounter this problem. I don't think any kind of specific timing delay is a good idea; it would be better to figure out what exactly you are waiting for and then implement the correct handler.

For example, if you were waiting for the whole page to load before doing something, instead of having a 1 second delay, implement a document.onload handler, like so:

document.onload = function () {
    //your code here
}

As a side note, you might consider using SWFObject, as it makes your life a lot easier with regards to Flash and JavaScript.

这篇关于flashMovie.Play不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆