apache-flex - Adobe Air - 使用 Air 打开文件

标签 apache-flex flash actionscript-3 air

所以我创建了一个保存为自定义文件类型的 Air 应用程序。我在发布应用程序时设置了文件关联,当您双击文件时,它会打开 air 应用程序。我检测到应用程序已通过文件打开的钩子(Hook)是什么?显然,我需要检测到这一点,然后让应用程序自行打开文件。

最佳答案

收听invoke WindowedApplication上的事件或其nativeApplication .它有一个 arguments保存在此调用期间传递的字符串参数的数组属性。

The NativeApplication object of an AIR application dispatches an invoke event when the application is invoked.

The NativeApplication object always dispatches an invoke event when an application is launched, but the event may be dispatched at other times as well. For example, a running application dispatches an additional InvokeEvent when a user activates a file associated with the application.

Only a single instance of a particular application can be launched. Subsequent attempts to launch the application will result in a new invoke event dispatched by the NativeApplication object of the running instance. It is an application's responsibility to handle this event and take the appropriate action, such as opening a new application window to display the data in a file.

InvokeEvent objects are dispatched by the NativeApplication object (NativeApplication.nativeApplication). To receive invoke events, call the addEventListener() method of the NativeApplication object. When an event listener registers for an invoke event, it will also receive all invoke events that occurred before the registration. These earlier events are dispatched after the call to addEventListener() returns, but not necessarily before a new invoke event that might be might be dispatched after registration. Thus, you should not rely on dispatch order.


<mx:WindowedApplication creationComplete="init()">
  <mx:Script>
  <![CDATA[
     public function init():void
     {
          NativeApplication.nativeApplication.addEventListener(InvokeEvent.Invoke, onInvoke);
     }
     public function onInvoke(e:InvokeEvent):void
     {
          var args:Array = e.arguments;
          trace("There are " + args.length + " arguments");
          for(var i:int = 0; i < args.length; i++)
          {
               trace("Argument #" + i + " " + args[i]);
          }
     }
  ]]>
  </mx:Script>
</mx:WindowedApplication>

关于apache-flex - Adobe Air - 使用 Air 打开文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3634278/

相关文章:

apache-flex - Flash Builder 4.5 问题 : "Type was not found or was not a compile-time constant: "

android - Flex+Android 移动应用最佳教程

flash - 从外部禁用 .swf 文件中嵌入的链接?

flash - AS3 - 如何从基于文本的文件导入变量?

apache-flex - 在 Flex 中,将字典用作数据提供者的最佳方式是什么?

css - Flex 4,嵌入字体被截断的旋转水平标签

javascript - 通过颜色框内的 AS3 外部接口(interface)调用 javascript

jQuery 特色内容 slider 问题与嵌入式 Flash youtube 视频,溢出 div

Flash 标签顺序更改

algorithm - 需要基于图 block 的编辑器的算法