简体   繁体   中英

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:

$('#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. 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. Your ActionScript will look something like this:

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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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