Actionscript 3 如何显示没有顶层窗口的警报框?

Actionscript 3 如何显示没有顶层窗口的警报框?,actionscript-3,air,Actionscript 3,Air,AdobeAIR提供了Alert.show()。但是,如果没有像典型托盘示例(“示例:创建没有窗口的应用程序”)中那样的顶层窗口,则此操作似乎会失败: 在这种情况下,我无法使Alert.show()工作。似乎也没有警报() 在这种情况下,是否有任何方法可以显示警报提示(模态或非模态),而无需重新设计控制盘 风道应用程序框架示例: <?xml version="1.0" encoding="utf-8"?> <s:WindowedApplication xmlns:fx="ht

AdobeAIR提供了Alert.show()。但是,如果没有像典型托盘示例(“示例:创建没有窗口的应用程序”)中那样的顶层窗口,则此操作似乎会失败:

在这种情况下,我无法使Alert.show()工作。似乎也没有警报()

在这种情况下,是否有任何方法可以显示警报提示(模态或非模态),而无需重新设计控制盘

风道应用程序框架示例:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/mx"
                       windowComplete="init(event)" visible="false">
 <fx:Script>
  <![CDATA[
   import flash.events.InvokeEvent;

   import mx.controls.Alert;
   import mx.events.CloseEvent;

   import mx.events.AIREvent;

   // As windows does not work without icon, we MUST embed it.
   // Stories told differently on the net are void.
   [Embed(source="icons/AIRApp_16.png")]  private var img16:Class;
   [Embed(source="icons/AIRApp_32.png")]  private var img32:Class;
   [Embed(source="icons/AIRApp_48.png")]  private var img48:Class;
   [Embed(source="icons/AIRApp_128.png")] private var img128:Class;

   private function helloworld(evt:Event):void {
    //This does not work
    Alert.show("hello world");
   }

   private function closer(e:CloseEvent):void
   {
    if (e.detail == Alert.YES) {
     NativeApplication.nativeApplication.icon.bitmaps = [];
     NativeApplication.nativeApplication.exit();
    }
   }

   private function doexit(event:Event):void {
    //This does not work either
    Alert.show("Really?","Exit application", Alert.YES | Alert.NO | Alert.NONMODAL, null, closer, null, 3);
   }

   protected function init(event:AIREvent):void {

    NativeApplication.nativeApplication.autoExit = false;

    var iconMenu:NativeMenu = new NativeMenu();

    var exitCommand:NativeMenuItem = iconMenu.addItem(new NativeMenuItem("Exit"));
    exitCommand.addEventListener(Event.SELECT, doexit);

    NativeApplication.nativeApplication.icon.bitmaps = [new img16, new img32, new img48, new img128];

    if (NativeApplication.supportsSystemTrayIcon) {

     var systray:SystemTrayIcon = NativeApplication.nativeApplication.icon as SystemTrayIcon;
     systray.tooltip = "Monitor Application";
     systray.menu = iconMenu;
     systray.addEventListener(ScreenMouseEvent.CLICK, helloworld);

    } else if (NativeApplication.supportsDockIcon) {

     var dock:DockIcon = NativeApplication.nativeApplication.icon as DockIcon;
     dock.menu = iconMenu;
     NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, helloworld);
    }
   }

  ]]>
 </fx:Script>
 <fx:Declarations>
  <!-- Platzieren Sie nichtvisuelle Elemente (z. B. Dienste, Wertobjekte) hier -->
 </fx:Declarations>
</s:WindowedApplication>


请注意“visible=false”必须保留,即使这是导致问题的原因。

否。Air和Flex中的应用程序都是根级别的对象。所有警报都必须是该对象的子对象。如果父级的visible=false,则不会看到子级

对不起


在调用Alert.show()之前,您是否考虑过将visibility设置为true?

顺便说一句,这些图标可以在AIR SDK示例文件夹中找到。谢谢,我很担心这一点。显示警报时,应隐藏窗口。所以我想我只有两个选择:A)重新发明轮子,创建一个myAlert窗口类,或B)将主窗口切换为透明和无铬,这样它实际上就不会显示并使用Alert.show()好吧,我选择变体A)然后,叹气。谢谢