The new Flex 3.4 SDK has been released. Since Adobe still hasn’t gotten around to fixing this bug, I’ve again taken it upon myself to release my MonkeyPatched code for Flex 3.4 that allows you to use the Flex DragManager along side the Native DragManager in an AIR app. You can grab the code from SVN from my google code site.


Post to Twitter

Posted by Andrew, filed under AIR, as3, Flex, MonkeyPatch. Date: August 28, 2009, 12:53 pm | No Comments »

Off and on, I’ve been working making the Flex DragManager work in AIR. I’ve been vocal in trying to get SDK-13983 fixed. This feature is really useful because you have no control over the DragProxy’s alpha value in AIR because it’s controlled by the operating system. If all operating systems defaulted to 0.5 alpha, all would be well, but OSX thinks that the drag proxy should be completely opaque and Windows thinks it should be 0.5.

The MonkeyPatch to fix this issue was posted to my Google code repository. Its only problem was that the mouse cursor for drag feedback disappeared when you were using a child window. I’ve added one small patch to UIComponent which fixes this issue. Grab the latest code if this is of interest to you. Let me know here if you have trouble with it.


Post to Twitter

Posted by Andrew, filed under AIR, as3, MonkeyPatch. Date: March 16, 2009, 12:03 pm | 2 Comments »

If you want to use both the nice Flex Dragmanager in an AIR app, you need to use a monkeypatch to make it work. I’ve taken the code about as far as I can on my own, so I’d like to enlist my reader’s help.

What you can do:
1.) Vote on https://bugs.adobe.com/jira/browse/SDK-13983
2.) Figure out how the low-level DragManager code works (better than I can) and help work on the monkeypatched code at http://code.google.com/p/andrewwestberg/

What works:
1.) Using Flex dragmanager inside an AIR WindowedApplication.
2.) Using the AIR dragmanager in the same app.

What’s broken:
1.) Using the Flex Dragmanager inside mx:Window. The cursor disappears while dragging.
2.) Flex dragmanager between mx:Windows (not sure DragManager was ever designed for this)
3.) Other stuff I haven’t tested yet.

Post to Twitter

Posted by Andrew, filed under AIR, as3, Flex, MonkeyPatch. Date: February 2, 2009, 2:54 pm | No Comments »

Last April, I had a blog post about how to use both the Native and Flex DragManagers at the same time by monkey-patching an AIR 1.0 application. I’ve since updated the code for AIR 1.5. This file contains the code to add to your project in order to monkey-patch the necessary DragManager-related classes. In no way do I make any claims about this code, support it, etc, etc… don’t sue me.


Post to Twitter

Posted by Andrew, filed under AIR, Flex, MonkeyPatch. Date: January 10, 2009, 10:11 am | No Comments »

I was sitting here at 360Flex|Milan and I had a conversation with Michael Labriola about DragManagers in AIR. We both lamented that in Flexbuilder 3 beta 2, we were able to use both the NativeDragManager and the DragManager at the same time (albeit it was a bit hacky). In an earlier post, I demonstrated a MonkeyPatch that allowed you to use the Flex DragManager inside a WindowedApplication in AIR. This was great, but you lose the ability to use Native Dragging/Dropping in your AIR app. This evening, I was finally pissed off enough to rewrite the DragManager how I think Adobe SHOULD have done it in the first place. You use the DragManager class for both Native and Flex-based drag/drop and it’ll pretty much figure out which one you wanted to use. If you’re doing manual Native dragging OUT of your app, the doDrag() method has an additional boolean value at the end to specify that it’s supposed to begin a native drag operation. I’m not going to go into a ton of detail on how it was done, but the code is posted below with view-source enabled. DragManager and SystemManager have been MonkeyPatched.  It’s been liberally commented, so hopefully you can figure it out. Post a comment if you have trouble with it or it screws up because I missed catching a bug here or there.


Post to Twitter

Posted by Andrew, filed under 360 Flex, AIR, MonkeyPatch. Date: April 8, 2008, 4:08 pm | 7 Comments »

I’m not really sure what Adobe has been thinking regarding DragManagers in Flex/AIR. The code makes a very basic and very WRONG assumption that in an AIR app using WindowedApplication, you will only ever want to use the NativeDragManager class. DragManager loads up a singleton class to handle drag and drop. Depending on whether your app is AIR or Flex and what your top-level container is you either get DragManagerImpl (the flex drag manager) or NativeDragManagerImpl. Unfortunately, this class has some really annoying limitations. You can’t specify an alpha level for the drag proxy. It’s hardcoded to 0.5 and there’s nothing you can do about it. Here’s what adobe has to say about it…

When a Flex application runs in Adobe® AIR™, you can control whether the application uses the Flex drag manager or the AIR drag manager. These drag managers are implemented by the classes mx.managers.DragManager (Flex drag manager) and flash.desktop.NativeDragManager (AIR drag manager).

Internally, the Flex mx.managers.DragManager class uses an implementation class to determine which drag manager to use. It uses either the Flex mx.managers.DragManagerImpl class, or the AIR mx.managers.NativeDragManagerImpl class.

By default, a Flex application defined by the <mx:Application> tag uses the Flex drag-and-drop manager, even when the Flex application runs in AIR. If you run your Flex application in AIR, and you want to take advantage of the AIR drag-and-drop manager to drag and drop items from outside of AIR, then you must configure the Flex mx.managers.DragManager class to use the AIR drag-and-drop manager.

There are three scenarios that determine which drag-and-drop manager your Flex application uses when running in AIR:

  1. Your main application file uses the <mx:Application> tag. In this scenario, you use the Flex drag-and-drop manager, and cannot drag and drop items from outside of AIR.
  2. Your main application file uses the <mx:WindowedApplication> tag. In this scenario, you use the AIR drag-and-drop manager, and can drag and drop items from outside of AIR.
  3. Your main application file uses the <mx:Application> tag, but loads the AIR drag-and-drop manager as represented by the mx.managers.NativeDragManagerImpl class. In this scenario, you use the AIR drag-and-drop manager, and can drag and drop items from outside of AIR.

Now what am I to do if I want option 4? I want all the window dressing goodness that comes with WindowedApplication like maximize, minimize, and a status bar, but I want the fully customizable Flex version of the drag manager implementation. Time to MONKEYPATCH!

The first thing you’ll need is to copy the framework classes mx.managers.SystemManager and mx.core.Version into your AIR app at the right locations.

Next, you edit one line of code in SystemManager.as so that it loads the DragManagerImpl instead of NativeDragManagerImpl. Find the method docFrameHandler. You should see a bit of code that looks like this…

    if (Capabilities.playerType == "Desktop")

        // Make this call to create a new instance of the DragManager singleton.
        // This will allow the application to receive NativeDragEvents that originate
        // from the desktop.
        // if this class is not registered, it's most likely because the NativeDragManager is not
        // linked in correctly. all back to old DragManager.
        if (Singleton.getClass("mx.managers::IDragManager") == null)

Now change to look like this…

    if (Capabilities.playerType == "Desktop")

Enjoy your AIR app with the Flex DragManager goodness.

Post to Twitter

Posted by Andrew, filed under AIR, as3, Flex, MonkeyPatch. Date: February 26, 2008, 8:27 pm | 1 Comment »