Is there a way JavaScript can detect clicks (or mousedown, mouseup) that happen on Flash objects?
I have tried:
- Attaching the 'mouseup', 'mousedown', and 'click' events to the Flash object using attachEvent/addEventListener
- Directly attaching the 'onmouseup', 'onmousedown', 'onclick' events inline on the Flash object
- Switching from event 'bubbling' to event 'capturing' (only works in Firefox/Safari)
I need this to work in IE6+, Firefox 2+, and Safari 3+.
Thanks for any help! -Dave
Is there a way JavaScript can detect clicks (or mousedown, mouseup) that happen on Flash objects?
I have tried:
- Attaching the 'mouseup', 'mousedown', and 'click' events to the Flash object using attachEvent/addEventListener
- Directly attaching the 'onmouseup', 'onmousedown', 'onclick' events inline on the Flash object
- Switching from event 'bubbling' to event 'capturing' (only works in Firefox/Safari)
I need this to work in IE6+, Firefox 2+, and Safari 3+.
Thanks for any help! -Dave
Share Improve this question edited Jul 21, 2009 at 14:32 asked Jul 21, 2009 at 14:27 ArtzStudioArtzStudio3 Answers
Reset to default 6I found this at http://progproblems.blogspot./2009/08/javascript-onclick-for-flash-embeded.html
1) Set the param wmode to transparent. This allows the object containing the flash to receive the javascript onclick.
2) Use onmousedown insted of onclick. In spite of using wmode transparent, some browsers still wont call the onclick, but they do call onmousedown.
The code looks like this:
<div onmousedown="clickBanner(1)">
<object>
<param name="movie" value="3.swf">
<param name="wmode" value="transparent" />
<embed wmode=transparent allowfullscreen="true" allowscriptaccess="always" src="3.swf"></embed>
</object>
</div>
It work for my needs =)
Do you own the flash objects?
We implemented call-backs from Flash to JavaScript when flash detects clicks. But we own the flash app and can manage the interaction.
Use the YAHOO yui.
If ( YAHOO.deconcept.SWFObjectUtil.getPlayerVersion().major == 0 ) {
alert("error");
}