Flex air执行Bat文件,打开关闭文件
来源:互联网 发布:百度人工智能发布会 编辑:程序博客网 时间:2024/06/04 04:57
RunFile.as文件,这个文件负责脚本打开文件,关闭文件操作,里面有调用Bat文件的操作,当然,也是通过NativeProcess类来实现的。
具体代码如下所示:
package com.floor.screen.redevelop.app{import flash.desktop.NativeProcess;import flash.desktop.NativeProcessStartupInfo;import flash.filesystem.File;public class RunFile{//var file:File = new File(); // 文件路径 //C:/Users/LONMID/Desktop/一卡通茶话会_一卡通.docxpublic var urlStr:String = "C:/Users/LONMID/Desktop/结网.pdf"; public var file:File ;public function RunFile(){file = new File(urlStr); }public function openFile():void{file = new File(urlStr); file.openWithDefaultApplication();}/** * 关闭文件 **/ public function closeFile():void{//file = new File("C:/Users/LONMID/Desktop/ccc.exe"); //file.openWithDefaultApplication();var cmdFile:File=new File();cmdFile = cmdFile.resolvePath("C:/WINDOWS/system32/cmd.exe");var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();nativeProcessStartupInfo.executable = cmdFile;var processArgs:Vector.<String> = new Vector.<String>();processArgs[0] = "/c C:/Users/LONMID/Desktop/ccc.bat "; //上面执行批处理的方式方法// C:/Users/LONMID/Desktop/ccc.batnativeProcessStartupInfo.arguments=processArgs;var process:NativeProcess = new NativeProcess();process.start(nativeProcessStartupInfo); }}}
2.调用这个as的mxml文件,如下所示:
<?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"><fx:Declarations><!-- 将非可视元素(例如服务、值对象)放在此处 --></fx:Declarations><fx:Script><![CDATA[import com.floor.screen.redevelop.app.RunFile ;/** * 打开文件测试 **/ protected function button1_clickHandler(event:MouseEvent):void{var f:RunFile = new RunFile();f.openFile();}/** * 打开下一个文件测试 * 要回来半闭生一个文件 **/ protected function button2_clickHandler(event:MouseEvent):void{var f:RunFile = new RunFile();f.closeFile();}]]></fx:Script><s:Button x="112" y="83" label="txt" click="button1_clickHandler(event)"/><s:Button x="201" y="83" label="paf" click="button2_clickHandler(event)"/></s:WindowedApplication>
注意:也要在配置文件中添加如下代码:
<supportedProfiles>extendedDesktop</supportedProfiles>
- Flex air执行Bat文件,打开关闭文件
- AIR是什么?.air文件如何打开?flex如何运行air文件
- AIR是什么?.air文件如何打开?flex如何运行air文件
- .bat文件执行不自动关闭窗口
- [BAT]执行工具,自动打开文件
- flex AIR 打开PDF文件(代码实现)
- flex调用.bat文件
- flex air 写文件注意事项
- Air flex 读/写文件
- bat打开文件
- java执行.bat文件
- c# 执行bat文件
- C# 执行 bat文件
- C#执行bat文件
- .bat文件执行问题
- bat文件 执行路径
- C# 执行 .Bat文件
- 程序执行bat文件
- centos+apahce+subversion安装配置
- p7结构的数字信封
- cocos2d-x总结(四)win32环境下响应键盘消息
- Unity网络通信(二)Unity Network 聊天
- ZOJ 1045 HangOver
- Flex air执行Bat文件,打开关闭文件
- Linux远程拷贝之ftp与scp命令
- sprintf与snprintf
- 关于android中的隐藏布局
- hash算法
- 对m3u8解释,是一种列表文件格式
- ZOJ 1048 Financial Management
- ZOJ 1049 I Think I Need a Houseboat
- Nginx 简单的负载均衡配置示例