Monthly Archives: September, 2008

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>