Wednesday, April 30, 2008

A few notes on AIR

To remove the window chrome in an AIR app, there are a few steps you need to take.

1. In the application's application.xml file, set the systemChrome tag to none.

2. Set the transparent tag to true.

3. Flex automatically starts with the tag. This is fine if you want the chrome, but if you don't you'll need to change this to the standard tag.

This should hide the chrome. You will need to provide functions for moving, resizing, and closing the application.

If you need to drag/move a window in AIR, stage.window.startMove() does not work. Its stage.nativeWindow.startMove(). window was replaced by nativeWindow.

To close the application, add a function to handle the close event and include this call:

stage.nativeWindow.close();

Wednesday, April 23, 2008

Showing the hand cursor on a Sprite with Text in it

In Actionscript 3, you don't automatically get a hand cursor over a sprite/movieclip, even if it has a MouseEvent.CLICK event listener attached to it. You have to set two properties in order to see the hand cursor:

var sp:Sprite = new Sprite();
sp.buttonMode = true;
sp.useHandCursor = true;

However, this doesn't help if you have any content within the sprite that could be clickable/selectable. To get the hand cursor when the sprite has children, you must also do:

sp.mouseChildren = false;

And depending on the events attached, you may also need:

sp.mouseEnabled = true;