13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Taskbar icons in AIR<br />

System tray icon m<strong>en</strong>us<br />

Adobe AIR 1.0 and later<br />

You can add a m<strong>en</strong>u to the system tray icon by creating a NativeM<strong>en</strong>u object and assigning it to the<br />

NativeApplication.nativeApplication.icon.m<strong>en</strong>u property (no default m<strong>en</strong>u is provided by the operating<br />

system). Access the system tray icon m<strong>en</strong>u by right-clicking the icon.<br />

System tray icon tooltips<br />

Adobe AIR 1.0 and later<br />

Add a tooltip to an icon by setting the tooltip property:<br />

NativeApplication.nativeApplication.icon.tooltip = "Application name";<br />

System tray icon ev<strong>en</strong>ts<br />

Adobe AIR 1.0 and later<br />

The SystemTrayIcon object refer<strong>en</strong>ced by the NativeApplication.nativeApplication.icon property dispatches a<br />

Scre<strong>en</strong>MouseEv<strong>en</strong>t for click, mouseDown, mouseUp, rightClick, rightMouseDown, and rightMouseUp ev<strong>en</strong>ts. You<br />

can use these ev<strong>en</strong>ts, along with an icon m<strong>en</strong>u, to allow users to interact with your application wh<strong>en</strong> it has no visible<br />

windows.<br />

Example: Creating an application with no windows<br />

Adobe AIR 1.0 and later<br />

The following example creates an AIR application which has a system tray icon, but no visible windows. (The visible<br />

property of the application must not be set to true in the application descriptor, or the window will be visible wh<strong>en</strong><br />

the application starts up.)<br />

package<br />

{<br />

import flash.display.Loader;<br />

import flash.display.NativeM<strong>en</strong>u;<br />

import flash.display.NativeM<strong>en</strong>uItem;<br />

import flash.display.NativeWindow;<br />

import flash.display.Sprite;<br />

import flash.desktop.DockIcon;<br />

import flash.desktop.SystemTrayIcon;<br />

import flash.ev<strong>en</strong>ts.Ev<strong>en</strong>t;<br />

import flash.net.URLRequest;<br />

import flash.desktop.NativeApplication;<br />

public class SysTrayApp ext<strong>en</strong>ds Sprite<br />

{<br />

public function SysTrayApp():void{<br />

NativeApplication.nativeApplication.autoExit = false;<br />

var icon:Loader = new Loader();<br />

var iconM<strong>en</strong>u:NativeM<strong>en</strong>u = new NativeM<strong>en</strong>u();<br />

var exitCommand:NativeM<strong>en</strong>uItem = iconM<strong>en</strong>u.addItem(new NativeM<strong>en</strong>uItem("Exit"));<br />

exitCommand.addEv<strong>en</strong>tList<strong>en</strong>er(Ev<strong>en</strong>t.SELECT, function(ev<strong>en</strong>t:Ev<strong>en</strong>t):void {<br />

Last updated 6/6/2012<br />

649

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!