我怎样才能克服“NPObject上的错误调用方法”和播放()一个SWF? [英] How can I overcome "Error calling method on NPObject" and Play() a SWF?

查看:424
本文介绍了我怎样才能克服“NPObject上的错误调用方法”和播放()一个SWF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个测验系统。通常,每个问题都使用jpeg图像。但是其中一些测验则以动画.SWF文件为特色。一旦用户点击了答案,我想用jquery swfobject来调用play()方法。

我的解决方案在本地工作正常,但是当我尝试在线运行时,它会抛出NPObject上的错误调用方法!消息。

测验HTML位于www.somedomain.com,SWF位于images.somedomain.com。所以,我猜这是一个跨域的事情。

麻烦对我来说,我对Flash一无所知......如何编辑SWF文件,任何关于Flash属性的东西等等。



以下是我的代码示例:

 < div class = 照片 > 
< object data =http://images.somedomain.com/q1tattooquiz.swftype =application / x-shockwave-flashwidth =600height =350>
< param name =movievalue =http://images.somedomain.com/q1tattooquiz.swf>
< param name =wmodevalue =opaque>
< / object>
< / div>

和javascript:

  if(hasFlash){
$('#question'+ quesNum +'.photos')。flash(function(){this.Play();});



$ b $ p
$ b

这非常简单,正如我所说的,它可以在我的电脑上正常工作。但是一旦上传,就会出错。

我可以在javascript中添加什么来使这些文件正常工作?

解决方案

Kirkman14,

除了allowScriptAccess之外,确保您正在使用正确数量的参数调用函数,匹配AS声明。如果你的AS声明:
$ b $ pre $ function playSound(event:MouseEvent):void {
// code here
}

然后确保您使用相应的函数 playSound(null)
我自己经历过这个。


I am working on a quiz system. Normally it uses jpeg images with each question. But a few of the quizzes instead feature animated .SWF files. I want to use jquery swfobject to call the play() method, once the user has clicked on an answer.

My solution works fine locally, but when I try to run it online, it throws the "Error calling method on NPObject!" message.

The quiz HTML is located on www.somedomain.com and the SWFs are on images.somedomain.com. So, I'm guessing this is a cross-domain thing.

Trouble for me is, I don't know anything about Flash... how to edit SWF files, anything about Flash attributes, or the like.

Here's an example of my code:

<div class="photos">
    <object data="http://images.somedomain.com/q1tattooquiz.swf" type="application/x-shockwave-flash" width="600" height="350">
        <param name="movie" value="http://images.somedomain.com/q1tattooquiz.swf">
        <param name="wmode" value="opaque">
    </object>
</div>

And the javascript:

if (hasFlash) {
    $('#question'+quesNum+' .photos').flash(function() { this.Play(); } );
    }

It's pretty simple, and as I said, it works fine on my PC. But once uploaded, it errors out.

What can I add to my javascript to make these files work right?

解决方案

Kirkman14,

Apart from the allowScriptAccess thingy, make sure you are calling the functions with the correct number of parameters, matching AS declaration. If your AS declares:

function playSound(event:MouseEvent):void{
// code here
}

then make sure you use the function accordingly playSound(null). I've been through this myself.

这篇关于我怎样才能克服“NPObject上的错误调用方法”和播放()一个SWF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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