flash platform! {desktop, mobile, touch screen…}


Modules and DragManager bug in Flex 3
June 25, 2009, 11:53 pm
Filed under: AIR, Flex | Tags: , , , , , , ,

In my last RIA project based on Flex 3, I find a bug working with modules that I’d like to sharing in this blog.

I create a dashboard where 4 custom components, that extend Panel component, load in a ModuleLoader differents sections.
In those sections there are components based on List component and when I run my project I’ve this kind of error:

TypeError: Error #1034: Type Coercion failed: cannot convert mx.managers::DragManagerImpl@21ef6df9 to mx.managers.IDragManager.

Surfing on web I don’t find anything about this kind of problem, finally on JIRA Adobe Flex bugs, I find it!
You can find workaround on JIRA ticket, it’s so easy to solve it, you only create a new instance of DragManager in your Default Application and everything works well.
This bug is created because you have more instance of DragManager in this sample, but DragManager in Flex framework is used like a Singleton so only one instance per time.
Each module has a List component that use DragManager when you have in the same application 2 or more modules you must put in Default Application file a DragManager instance and that’s it!
I think could be useful for anybody in the same situation.


8 Comments so far
Leave a comment

Good find and thanks! I had run into that very issue awhile back never really finding the culprit and finally the UX changed such that it was no longer an issue. Guess I dodged a bullet back then.

Comment by jwopitz

[...] This bug is created because you have more instance of DragManager in this sample, but DragManager in Flex framework is used like a Singleton so only one instance per time. See the rest here: Modules and DragManager bug in Flex 3 « flash platform! {desktop … [...]

Pingback by Modules and DragManager bug in Flex 3 « flash platform! {desktop … | Adobe Tutorials

Great solution. Thanks very much.
I had same problems and this was my solution, I insertet in Main.mxml the following and it works!

Comment by Peter

In a mx:script put the two lines
Line1: import mx.managers.DragManager;
Line2: private var dummy:DragManager;

Comment by Peter

I suggest to take a look at this great post about this issue: http://blogs.adobe.com/aharui/2007/03/modules.html

Comment by lucamezzalira

Hava a look that solution at http://www.flexjunk.com/2008/02/26/monkeypatching-the-dragmanager-in-air-10/

Comment by Ivan

Thanks a million for this; solved the issue like magic. Amazing workaround to a puzzling issue :-)

Comment by Ugo

With modules you can have a module-wide singleton or an application-wide singleton depending on whether you import the singleton class also in the main application or not. I’ve written a post on my blog about this that demonstrates the different behaviors. I think it could be useful to avoid strange behaviors of the singletons in each modular Flex application. You can check it at http://www.devahead.com/blog/2010/03/beware-of-singleton-in-flex-modules/

Comment by Andrea Bresolin




Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>