26  Apr
flexvizgraphlib

I was working on enhancements to the NitroLM admin tool for visualizing users in the system and what computers they’ve used. When it comes to licensing software, knowledge is power, and the visual links really demonstrate well when someone isn’t doing what they’re supposed to be doing. We called this guy in the UK about how his demo of our software was going. He thought it was great and really useful software, but he didn’t want to have his boss actually “PURCHASE” it for him. His solution was to keep re-registering for demos under new gmail accounts. His machine is going to be blacklisted in the system in short order.

To do the visualization, I used the open-source library flexvizgraph. You may remember it from the BirdEye application. This new feature in NitroLM really highlights the power of the Flex/AIR visual environment.

stealing software

Posted by Andrew, filed under AIR, Flex. Date: April 26, 2008, 5:47 pm | 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.

DualDragManagers.air

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

Here are my 3 articles for InsideRIA on Encryption in Flex applications.

Encryption in Flex Applications 1 - Simulate EncryptedLocalStore

Encryption in Flex Applications 2 - SWC AS3 Library Encryption

Encryption in Flex Applications 3 - NitroLM SWF Encryption

Posted by Andrew, filed under AIR, Flex, as3, encryption, security. Date: April 4, 2008, 12:25 pm | No 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.
monkeypatch1

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...

Actionscript:
  1. if (Capabilities.playerType == "Desktop")
  2.     {
  3.         Singleton.registerClass("mx.managers::IDragManager",
  4.             Class(getDefinitionByName("mx.managers::NativeDragManagerImpl")));
  5.  
  6.         // Make this call to create a new instance of the DragManager singleton.
  7.         // This will allow the application to receive NativeDragEvents that originate
  8.         // from the desktop.
  9.         // if this class is not registered, it's most likely because the NativeDragManager is not
  10.         // linked in correctly. all back to old DragManager.
  11.         if (Singleton.getClass("mx.managers::IDragManager") == null)
  12.             Singleton.registerClass("mx.managers::IDragManager",
  13.                 Class(getDefinitionByName("mx.managers::DragManagerImpl")));
  14.     }

Now change to look like this...

Actionscript:
  1. if (Capabilities.playerType == "Desktop")
  2.     {
  3.         Singleton.registerClass("mx.managers::IDragManager",
  4.             Class(getDefinitionByName("mx.managers::DragManagerImpl")));

Enjoy your AIR app with the Flex DragManager goodness.

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