AIR 常用技巧
2015-07-29 22:40
387 查看
1.air打开关联类型文件
如果该应用程序是由于文件类型关联而被调用,则文件的完整路径将包含在命令行参数中。应用程序可通过以下方法处理 invoke 事件:即向其 NativeApplication 对象注册侦听器,
NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onInvokeEvent);
air.NativeApplication.nativeApplication.addEventListener(air.InvokeEvent.INVOKE, onInvokeEvent);
详见:
<a target=_blank href="http://help.adobe.com/zh_CN/AIR/1.1/devappsflex/WS5b3ccc516d4fbf351e63e3d118676a5d46-8000.html#WS5b3ccc516d4fbf351e63e3d118666ade46-7e1a" target="_blank">http://help.adobe.com/zh_CN/AIR/1.1/devappsflex/WS5b3ccc516d4fbf351e63e3d118676a5d46-8000.html#WS5b3ccc516d4fbf351e63e3d118666ade46-7e1a</a>
详见:
<a target=_blank href="http://help.adobe.com/zh_CN/AIR/1.1/devappsflex/WS5b3ccc516d4fbf351e63e3d118676a5d46-8000.html#WS5b3ccc516d4fbf351e63e3d118666ade46-7e1a" target="_blank">http://help.adobe.com/zh_CN/AIR/1.1/devappsflex/WS5b3ccc516d4fbf351e63e3d118676a5d46-8000.html#WS5b3ccc516d4fbf351e63e3d118666ade46-7e1a</a>
2.air 打开系统文件目录
var file:File = new File(directoryPath); file.openWithDefaultApplication();
3.AIR NativeProcess 调用bat
<span style="white-space: pre;"><span style="font-family:Arial, Helvetica, sans-serif;"><span style="background-color: rgb(255, 255, 255);"> </span></span>NativeProcess在windows下只能调用exe</span>, 所以,直接把.bat的路径传入nativeProcess的参数中肯定不行。解决方案是用NativeProcess调用cmd.exe,然后将bat的路径以参数传入cmd.exe。这样就可以通过cmd来执行bat了。
<span style="white-space:pre"> </span><span style="font-weight: normal;">var batFile:File = new File();
NativeApplication.nativeApplication.autoExit = true;
batFile = batFile.resolvePath("C:/Windows/System32/cmd.exe");
var batPath:String = File.applicationDirectory.nativePath + "\\mybat.bat";
var process:NativeProcess = new NativeProcess();
var processArg:Vector.<String> = new Vector.<String>();
processArg[0] = "/c";/加上/c,是cmd的参数
processArg[1] = batPath;
processArg[2] = "%1";//参数1,传入cmd内
var info:NativeProcessStartupInfo = new NativeProcessStartupInfo();
info.executable = batFile;
info.arguments = processArg;
process.addEventListener(NativeProcessExitEvent.EXIT, onExit);
process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, outputHandlers);
process.start(info);</span></span>
4.调用browsfor文件或文件夹时,默认定位到剪贴板位置
<span style="font-weight: normal;"><span style="white-space:pre"> </span>var msg:String = Clipboard.generalClipboard.getData(ClipboardFormats.TEXT_FORMAT) as String; var f:File = new File(); try { f.nativePath = msg; } catch (evt:ArgumentError) { trace("参数不合法"); }</span>
相关文章推荐
- aircrack-ng判断网卡是否兼容
- 2015 Multi-University Training Contest 3 1006 Beautiful Set
- K - After Training CodeForces 195B-找规律
- Cube painting
- MRC模式下property 的retain带来的内存泄露
- 2015 Multi-University Training Contest 3 1004 painter
- PAT (Advanced Level) 1079. Total Sales of Supply Chain (25) 总叠加售价 BFS
- 2015 Multi-University Training Contest 3 1001 Magician
- hdu 2473 Junk-Mail Filter(并查集_虚节点)2008 Asia Regional Hangzhou
- hdu-5325 Crazy Bobo (2015 Multi-University Training Contest 3)
- Climbing Stairs
- 象棋AI算法(一)
- 【交换安全】DAI - Dynamic ARP Inspection 详解
- HDUOj BUS Fair 题目3420
- http://ourjs.com/detail/532bc9f36922aa7e1d000001
- Aircrack-ng指导教程
- LINK1123:failure during conversion to COFF:file invalid or corrupt
- HDU 5046 Airport
- The Brain vs Deep Learning Part I: Computational Complexity — Or Why the Singularity Is Nowhere Near
- The Brain as a Universal Learning Machine