You can do this if the event from flash "bubbles". When you dispatch the event from Flash, do this:
dispatchEvent(new Event("myEventName", true)); // that 'true' for bubbles, in the constructor
Then you should be able to capture it in Flex no problem, with:
addEventListener("myEventName", handler);
... as long as addEventListener
is called on a component at or above the SWFLoader.
If you can't modify the Flash SWF, or it's a complete black box, then you can just register a MouseEvent.CLICK
handler with useCapture = true
, and check to see if it's the right button:
swfLoader.addEventListener(MouseEvent.CLICK, swfLoader_clickHandler, true, 0, true);
protected function swfLoader_clickHandler(event:MouseEvent):void
{
if (event.target.name == "some_way_to_identify_the_button")
// do X
}
Hope that helps,
Lance