Workaround for error when loading PopUps from Modules

There have been some reports of runtime errors when Applications are loading multiple sub-applications (such as Modules and/or PopUps) from a single Application. One of the bugs with an example that I uploaded can be found here: SDK-13152. In the sample bugfile included with this bug, you can create a popup from a loaded module with no problem. However, once you unload the module and re-load it, you will get an error when attempting to create a popup from that module. The runtime error that you will get is:

TypeError: Error #1034: Type Coercion failed: cannot convert mx.managers::PopUpManagerImpl@13068c1 to mx.managers.IPopUpManager.
at mx.managers::PopUpManager$/get impl()
at mx.managers::PopUpManager$/createPopUp()
at main/addMyPopUp()
at main/___main_Button1_click()

To get around this error, you need to include the IPopUpManager class in your main Application:

import mx.managers.IPopUpManager;
private var iPopUpManager:IPopUpManager;

According to our developers, because of the design of the SingletonManager that supports a bootstrap topology, any time you get into a similar topology (where multiple sub-applications are loaded in a main Application), you need to move shared interfaces into the bootstrap. In this case it is the IPopUpManager, which we can be moved into the main application (effectively the bootstrap) via this two-line workaround.

A similar bug is reported with multiple sub-applications using the DragManager. Details can be found in SDK-995. In this scenario, the Application loaded different swfs using the SWFLoader into various views of a TabNavigator. These swfs both included a DataGrid using the DragManager. To get around the error, the Application needed to include:

import mx.managers.IDragManager;
private var iDragManager:IDragManager;

27 responses

  1. Thankyou so much! Been pulling my hair out over this!

  2. Thanks for the quick and elegant solution.

    I have noticed these errors also occurring even when you have an a listBase class (i.e. ComboBox, TileList, etc) with its drag enabling properties set to false. This solution also seems to have solved those issues as well.

    J

  3. Nice quick easy fix!

  4. Is there a way to “bootstrap” these classes if the main app is not FLEX? My main app is just an ActionScript 3 swf.

  5. @Paul – Since it’s AS3, you can compile a Flex app with these classes and load the swf using a flash Loader. Does that help?

    1. that doesnt seem to help at all. i get the exactly same problem, but i cant very well import mx.* into the main swf (non flex) ap. is there any workaround?

  6. Put next code in the main application and voila!, not more problems with “bootstrap”.

    import mx.managers.*;
    private var _dragManager:DragManager;
    private var _historyManager:HistoryManager;
    private var _popupManager:PopUpManager;

  7. Man, you rule!!! my application is 100% functional now. Thanks for the post, you solve a really big problem with a very nice solution.

  8. Oh man… THANK YOU THANK YOU THANK YOU. You just bought me some time to sleep.

  9. […] closest thing I could find on this out there, were people who were getting a runtime error in Flex 2 when their Modules had problems with the singleton classes such as PopUpManager and […]

  10. Thank you so much for this quick fix.

  11. This one saved a lot of headache!!!! Thanks πŸ™‚

  12. Oh fuck it’s a easy and efective solution

  13. I am trying to solve this problem since last 2 days……

    But your example is really good…… πŸ™‚

    Thanks a lot πŸ™‚

  14. Thank you so much! I spent such a long time trying to figure it out. Thank you for posting this!!!

  15. SECOND BUG found.
    when using my own component based on TitleWindow which have a simple class for Data handling, everything work fine until I reload the Module.
    After reloading the Module, the TitleWindow popup but I am not able to fill my public var class. I still get a null result. When I try to fill it, I don’t any error. I can initialize it with new classname(); but no effect.
    Have someone the same issue or any Idea??

    1. @tsedeke – Can you file a bug with your test case? If you want, you can post the bug here and I’ll have a look at it. To file a bug, go to http://bugs.adobe.com/flex. Thanks!

  16. Well I’m not absolutelly sure it’s a Bug.
    So I look arround and hope to find helping something.
    The Application is using Zendframework and Oracle as DB. You can download it here:http://www.sousgarden.com/vs.zip
    You can also test ist online. Just add to your hosts:
    visualstore.dev 87.156.45.81
    and call in your browser http://visualstore.dev/Flex/bin-debug/VisualStore.html
    You have to load module “Hersteller” and doubleClick a row.
    Thanks for helping.

  17. Well after testing a little bit more I have found out,
    that if I BIND a DataGrid getting data using RemoteObjects, everything work fine. I get the ROWs as objects defined in a class before. Using MyClass = datagrid.selectedItem as MyClass; work fine until I reload the Module.
    Then it crash.
    Why???

  18. Thank you, helped a lot!

  19. Awesome, was having problem with IDragManager because I had 2 modules, one with a linechart and the other with a piechart. For some reason, the “showdatatip” only worked on one or the other, never both. This fixed it.. You guys rule :):):)

  20. Thanks a lot! You just saved me a ton of time.

  21. Also I must say thank you a lot. It realy helped me.

  22. In Flex 4.x the following is not working
    import mx.managers.IPopUpManager;
    private var iPopUpManager:IPopUpManager;

    I have added the following and working fine ref: (https://bugs.adobe.com/jira/browse/SDK-16474)

    import mx.managers.IPopUpManager;
    private var iPopUpManager:IPopUpManager;

    1. Sorry Ignore Above post

      In Flex 4.x the following is not working

      import mx.managers.IPopUpManager;
      private var iPopUpManager:IPopUpManager;

      I have added the following and working fine ref: (https://bugs.adobe.com/jira/browse/SDK-16474)

      You’ll need to add the following code to the main MXML application:

      import mx.managers.PopUpManager;
      private var popUpManager:PopUpManager;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: