| <?xml version="1.0" encoding="utf-8"?> |
| <!-- |
| |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| |
| --> |
| <s:WindowedApplication |
| xmlns:fx="http://ns.adobe.com/mxml/2009" |
| xmlns:mx="library://ns.adobe.com/flex/mx" |
| xmlns:s="library://ns.adobe.com/flex/spark" |
| creationComplete="doCreationComplete();"> |
| |
| <fx:Script> |
| <![CDATA[ |
| import mx.controls.FlexNativeMenu; |
| import mx.events.FlexNativeMenuEvent; |
| |
| [Embed(source="TestImage.jpg")] |
| [Bindable] |
| public var TestImage:Class; |
| |
| private var menu1:FlexNativeMenu; |
| private var menu2:FlexNativeMenu; |
| |
| /** |
| * Set up the icon and menus. |
| **/ |
| private function doCreationComplete():void { |
| setUpIcon(); |
| |
| menu1 = new FlexNativeMenu(); |
| menu1.addEventListener(mx.events.FlexNativeMenuEvent.ITEM_CLICK, handleMenuItemClick); |
| menu1.dataProvider = menuData1; |
| menu1.labelField = "@label"; |
| menu1.showRoot = false; |
| |
| menu2 = new FlexNativeMenu(); |
| menu2.addEventListener(mx.events.FlexNativeMenuEvent.ITEM_CLICK, handleMenuItemClick); |
| menu2.dataProvider = menuData2; |
| menu2.labelField = "@label"; |
| menu2.showRoot = false; |
| |
| // Mac dock |
| dockIconMenu = menu1; |
| |
| // Windows system tray |
| systemTrayIconMenu = menu1; |
| |
| // Mac and Windows |
| menu = menu2; |
| } |
| |
| /** |
| * Set up the icon which appears in the sytem tray (Win) |
| * or the dock (Mac). |
| **/ |
| private function setUpIcon():void { |
| nativeApplication.icon.bitmaps = new Array(new TestImage().bitmapData); |
| } |
| |
| /** |
| * If someone chooses Exit from either menu, then exit. |
| **/ |
| private function handleMenuItemClick(e:mx.events.FlexNativeMenuEvent):void { |
| if(e.label == "Exit"){ |
| exit(); |
| } |
| } |
| ]]> |
| </fx:Script> |
| |
| <fx:Declarations> |
| <!-- We use this one for the system tray or dock. --> |
| <fx:XML format="e4x" id="menuData1"> |
| <root> |
| <menuitem label="Exit" /> |
| </root> |
| </fx:XML> |
| |
| <!-- We use this one for the menu on top. --> |
| <fx:XML format="e4x" id="menuData2"> |
| <root> |
| <menuitem label="File" > |
| <menuitem label="Exit" /> |
| </menuitem> |
| </root> |
| </fx:XML> |
| </fx:Declarations> |
| </s:WindowedApplication> |