简体   繁体   English

如何使用jQuery单击Flash对象?

[英]How do I Click on a Flash object with jQuery?

I have something like this: 我有这样的事情:

<object id="myflash"></object>

I've tried making jQuery click the object like so: 我试过让jQuery单击对象,如下所示:

$('#myflash').click();

But this doesn't work. 但这是行不通的。 Is there another way to do this? 还有另一种方法吗?

Do you want to focus it, or actually click on a certain point? 您要聚焦还是实际单击某个点?

You can probably use .focus() instead of .click() to focus the flash object. 您可能可以使用.focus()而不是.focus() .click()来聚焦Flash对象。 If you need to click on a certain spot, you should create a method in ActionScript that does what you want the click to do, and then call it. 如果需要单击某个位置,则应在ActionScript中创建一个方法,该方法执行您希望单击的操作,然后调用它。 Your ActionScript will look something like this: 您的ActionScript将如下所示:

import flash.external.ExternalInterface;
ExternalInterface.addCallback("sendTextToFlash", getTextFromJavaScript);
function getTextFromJavaScript(str):void {
    trace(str);
}

You then call the method with the name set in the addCallback call directly on the object: 然后,您可以直接在对象上使用在addCallback调用中设置的名称来调用该方法:

flashObject.sendTextToFlash('My string');

See this page for more info and a method that will get the object or embed so that it works correctly in all browsers. 有关更多信息以及将获取对象或嵌入该对象的方法,请参见此页面 ,以使其在所有浏览器中都能正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM