How to raise an event from a SWF in a SWFLoader to a parent Flex application

apache-flexevent handlingeventsswfloader

How can I raise an event from a SWF file loaded into a Flex application (using SWFLoader)?

I want to be able to detect

a) when a button is pressed
b) when the animation ends

Best Answer

You'll need to do 2 things:

  1. Dispatch an event from the loaded swf. Make sure the event bubbles if you sent it from nested views. Bubbling can be set through the bubbles property of the event.
  2. Listen to the event from your main application. I think you should be able to do that on the content property of the SWFLoader instance.

    mySWFLoader.content.addEventListener("myEvent", myEventHandler);