使用jquery调用AS3外部接口

发布于 2024-08-13 12:10:47 字数 1160 浏览 2 评论 0原文

我正在使用ExternalInterface 调用嵌入在html 页面中的Flash 应用程序。 以下代码工作正常(我正在使用按钮进行测试):

$(document).ready(function(){
    $("#button").click(function(){
        var app = document.getElementById('ApplicationID')
        console.debug(app)
        app.pageUnloading()
    })
})

因此,这可以正常调用 Flash 应用程序并打印:

<embed id="ApplicationID" width="600" height="400" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" allowscriptaccess="sameDomain" name="FlexMoeders" bgcolor="#cccccc" quality="high" src="ApplicationID.swf">

但是当我使用 jquery $# 方法通过 id 获取元素时,我收到了一个不同的对象:

$(document).ready(function(){
    $("#button").click(function(){
        var app = $("#ApplicationID")
        console.debug(app)
        app.pageUnloading()
    })
})

当我使用它时,我被告知:

app.pageUnloaded is not a function

并打印以下内容:

[embed#ApplicationID] 

我也尝试过:

var app = $("#ApplicationID").val()

var app = $("#ApplicationID").get(0)

但仍然没有成功。这里有人有什么想法吗?

I'm calling into a flash app embedded in a html page using the ExternalInterface.
The following code works fine (I'm using a button to test):

$(document).ready(function(){
    $("#button").click(function(){
        var app = document.getElementById('ApplicationID')
        console.debug(app)
        app.pageUnloading()
    })
})

So this calls into the flash app fine and prints:

<embed id="ApplicationID" width="600" height="400" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" allowscriptaccess="sameDomain" name="FlexMoeders" bgcolor="#cccccc" quality="high" src="ApplicationID.swf">

But when I use the jquery $# method of getting an element by id, I receive a different object back:

$(document).ready(function(){
    $("#button").click(function(){
        var app = $("#ApplicationID")
        console.debug(app)
        app.pageUnloading()
    })
})

When I use this I'm told:

app.pageUnloaded is not a function

and the following is printed:

[embed#ApplicationID] 

I have also tried:

var app = $("#ApplicationID").val()

var app = $("#ApplicationID").get(0)

But still no success. Does anyone have any ideas here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月棠 2024-08-20 12:10:47
var app = $('#ApplicationID')[0] 

或者

var app = $('#ApplicationID').get(0)

应该做同样的事情

var app = document.getElementById('ApplicationID')
var app = $('#ApplicationID')[0] 

or

var app = $('#ApplicationID').get(0)

should do the same thing as

var app = document.getElementById('ApplicationID')
脱离于你 2024-08-20 12:10:47

当您使用 $("#ApplicationID") 您将得到一个 jQuery 对象。

这就是为什么它不起作用。但 $("#ApplicationID").get(0) 实际上应该可以工作。

When you use $("#ApplicationID") you will get back a jQuery object.

That's why it doesn't work. But $("#ApplicationID").get(0) actually should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文