I am using Flash Builder 4 using the 4.1 SDK and exporting the project as an Air app. I am having trouble dispatching a custom event from a loaded swf using mx:SWFLoader. Both the loaded swf and the air app are compiled using the CustomEvent, which includes the "override public function clone():Event".
When dispatchEvent(new CustomEvent(CustomEvent.APP_BUTTON_CLICK, true, false, 'http://www.test.com')) is triggered in the loaded swf, the following error occurs: TypeError: Error #1034: Type Coercion failed: cannot convert events::CustomEvent@1620f641 to events.CustomEvent
Any ideas why this would happen?
Figured it out. The import paths need to match exactly in both the Flex and Flash side.
In Flex: import events.CustomEvent
In Flash: import events.CustomEvent.
Previously, the Flash class was located in "com.site.events". Once I moved it to "events", the error went away and the custom event was dispatched.