How to get a custom cursor in an AIR Window

I was testing custom cursors in an AIR Window this past week and I found some strange behavior. If tried to change the default cursor in an AIR Window by calling :

CursorManager.setBusyCursor()

The cursor in the main WindowedApplication changed rather than the cursor in my AIR Window. So, how could I change just the cursor in my AIR Window. The answer is to use a lower case “cursorManager” on the Window. So, I needed to call:

myAIRWindow.cursorManager.setBusyCursor();

Here is a full example in a simple AIR application –

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:WindowedApplication xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; layout=”vertical” creationComplete=”loadWin()”>
<mx:Script>
<![CDATA[
import mx.controls.List;
import mx.controls.Button;
import mx.controls.SWFLoader;
import mx.core.Window;
import mx.managers.CursorManager;

public var myNewWin:Window;
private function loadWin(): void
{
myNewWin = new Window();
var btn2:Button = new Button ();
btn2.label = “change cursor”;
btn2.addEventListener(“click”, busyCursor_handler);
var newL:List = new List();
newL.dropEnabled = true;
myNewWin.addChild(newL);
myNewWin.addChild(btn2);
myNewWin.open(true);
}

public function busyCursor_handler(event:MouseEvent): void
{
//This works

myNewWin.cursorManager.setBusyCursor();

//This does not work: CursorManager.setBusyCursor();
}
]]>
</mx:Script>
</mx:WindowedApplication>

10 responses

  1. Hi, i am developing AIR apps in AIR + AJAX, how do i can change use this code in my application, i have no clue to include this code, please help me?

  2. Hi!

    My question is the same. How can I use this code in my Air+Ajax app?

  3. I used this to do a change cursor recently in an ajax environment, and it work brilliantly. Great post, showed up when searching in google.

  4. You’re kidding me, right? WindowedApplication isn’t where I want to manage something like this, I’m using it as just a splash that launches Window components and then closes. Each instance has specific processes that would show the busy cursor, like db or remote calls. Why would I want to break encapsulation and handle something as simple as a cursor outside the component? And, lower-case cursorManager doesn’t exist on s:Window.

    Am I missing sonething here?

  5. Okay, my bad. Was looking at a borderContainer component which I thought was a Window. Stupid is as stupid does…

  6. Of course, this example has real life applications, perform an application where the database was sqlite and while inserting records (100) were amazed to hear the application while performing the process of the tables, so changing it was very useful

  7. THANK YOU! Sorry. I don’t normally all-cap something like that, but Adobe’s documentation is poor on this area. You rock!

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: