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

~ by jlafferty on September 4, 2008.

2 Responses to “How to get a custom cursor in an AIR Window”

  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?

Leave a Reply