AS3 ExternalInterface call using jquery

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 11:45:16

问题


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?


回答1:


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

or

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

should do the same thing as

var app = document.getElementById('ApplicationID')



回答2:


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.



来源:https://stackoverflow.com/questions/1860226/as3-externalinterface-call-using-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!