Need Flex Migration Help?
- Adobe ends Flash player support in 2020
- Flex apps will no longer function
- We can help migrate your app
I’ve been experimenting with the Flash CS5 JSFL API lately and ran across these handy methods adding and removing event listeners to the fl object. However, I discovered that the functionality has changed from what the documentation states. After digging around the internet for some answers with no luck, I finally contacted Adobe about it and sure enough here is what they say.
fl.addEventListener now returns an eventID (valid across FLA files for that Flash session) when you add an event listener. When you remove the event listener, you have to specify the event type and the event id.
Example for adding:
var evtID = fl.addEventListener("documentChanged", docChangedHandler);
Example for removing:
This affects Flash CS4 & Flash CS5. Hopefully this clears things up for people and hopefully the documentation will be updated soon. After experimenting with it while attempting to prevent duplicate event listeners from being added when working with a windowswf that has been opened and closed repeatedly, now you can derive a way to persist the id’s and keep your panel from adding duplicate listeners. Pretty handy I must say.