Posts Tagged ‘AIR 1.1’

AIR 1.1 – hiding the mouse cursor

Adobe AIR is out quite a while now and you might think that at least all the functions being in the FlashPlayer for years are implemented correctly. Obviously this is only wishful thinking because I wasn’t able to hide my mouse cursor through Mouse.hide() even though the documentation says that it’s possible. I couldn’t reproduce the same thing on Windows so I guess it’s only a problem on OSX and maybe Linux (but who really cares about linux?). After investigating quite a while I found out that the cursor disappears after moving it out of the window and back in or switch to another application and back but you can’t tell the user "please move your cursor out of the window and back in" or at least it’s not very nice and user-friendly. I tried every possible setting for the native window and finally found a workaround … wohoo.

Try the following in your document class and your cursor is gone, hopefully!

stage.nativeWindow.activate();
stage.nativeWindow.orderToBack();
stage.nativeWindow.orderToFront();
Mouse.hide();

Basically this sends the window behind all the other windows and brings it to the front again immediately. You won’t see the change or any flickering. After that you can hide your cursor.

Update 17.11.2008

Adobe just released AIR 1.5 but seems like this problem is still there. The workaround is still working so keep on rockin’ or should I say hiding

AIR 1.1 – Maximized Window at Startup

There are a lot of settings for the initial window in the application descriptor file but none for getting a maximized window at startup. To achieve that you have to call stage.nativeWindow.maximize() in your Document Class. This works fine but you’ll actually see the small window being maximized and this isn’t very cool. To avoid this you can set visible = false for the initial window in the descriptor file and show the window after maximizing it but take into account that the maximize() method is asynchronous and therefore setting stage.nativeWindow.visible = true right after the call won’t change anything. Use the NativeWindowBoundsEvent.RESIZE event to determine when your window size has changed.

...
public function Main()
{
	stage.nativeWindow.addEventListener(NativeWindowBoundsEvent.RESIZE, resize);
	stage.nativeWindow.maximize();				
}
private function resize(event : NativeWindowBoundsEvent) : void
{
	// show window + set keyboard and mouse focus
	stage.nativeWindow.activate();
}
...

Apparently this works on OSX but not on Windows. There the window has to be visible in order to maximize it. I didn’t do many tests so prove me wrong if you have other experiences.

About

Martin Rädlinger is an Interactive Developer & Designer. He specializes in interactive coding predominantly with ActionScript, but every new challenge is welcome. If you like his work feel free to get in touch with him. At the moment he's available for freelance work.

Contact

Martin Rädlinger
mail: mr [at] formatlos.de
web: www.formatlos.de
xing: Martin Rädlinger
linkedin: Martin Rädlinger
skype: martinraedlinger