views:

825

answers:

1

I am making a dynamic banner system which can handle img banners, as well as flash banners done with object/embed. The entire site makes heavy use of jQuery, including handling the 'click' events.

This obviously isn't a problem when it comes to tracking the clicks on the image itself (i track the click on the parent DIV tag. However, it fails when the advert is an SWF, as I suspected it would.

Is there a jQuery workaround that would allow me to capture a click on a Flash element with the DOM?

+3  A: 

If you have access to the source of SWF, you can use ExternalInterface to communicate with the containing html page.

//inside the flash movie:
stage.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void
{
   ExternalInterface.call("handleFlashClick", [parameters to the method]);
}

//javascript in the containing html page
function handleFlashClick()
{
  //call the jQuery method here.
}
Amarghosh
i don't have access to the source at all, it's a banner system that would allow customers to upload their own SWF banners to the system.With that said, would it be a better idea to link an 'in-house' banner which loads the client banner SWF as a movie within itself, giving my SWF control of the flash file, while still allowing untouched client SWF files to be uploaded??
David
That sounds like a good idea.
Amarghosh
Thank you for your help! :)
David