Select to view content in your preferred language

Loading widgets into a common Application domain

1103
0
04-28-2011 09:10 AM
KyleTraff
Emerging Contributor
My flex viewer 2.2 application currently contains a number of Widgets that are managed by the Widget Manager. When the user clicks on a widget (e.g. a Helper widget), the Widget Manager loads the widget into a separate sibling application domain with the following line of code:

> wgtInfo.load(null, null, null, moduleFactory); //wgtInfo = IModuleInfo

However, I am unable to use the widget's variables and functions later on.  I attempt to find the Helper widget from the Widget Manager's list of widgets, and I do successfully.  But when I try to caste the Helper Widget from type IBaseWidget (the interface all widgets share) to type HelperWidget, I receive the following error:

> TypeError: Error #1034: Type Coercion failed.....

This is because the application domain of the class trying to use the Helper widget is different from the application domain of the Helper Widget.  I tried to fix this by loading all widgets into the same application domain as the loader:

> wgtInfo.load(ApplicationDomain.currentDomain, null, null, moduleFactory);

I now get the following error whenever I attempt to load the Helper widget:

> TypeError: Error #1009: Cannot access a property or method of a null object reference.


How can I load my Helper widget into a common application domain that is accessible by the other widgets?
Tags (2)
0 Kudos
0 Replies