Flex air는 Excel, Word, PDF, Notepad, html 파일과 같은 로컬 파일을 호출합니다.
1.여기서 간단한 Notepad 작업을 예로 들면 다음과 같습니다.
package com.floor.screen.redevelop.app
{
	import flash.desktop.NativeApplication;
	import flash.desktop.NativeProcess;
	import flash.desktop.NativeProcessStartupInfo;
	import flash.display.MovieClip;
	import flash.events.IOErrorEvent;
	import flash.events.MouseEvent;
	import flash.filesystem.File;
	import flash.system.fscommand;
	
	
	public class CallEXE extends MovieClip
	{
		
		private var file:File=new File();
		private var nativeProcessStartupInfo:NativeProcessStartupInfo;
		
		
		public function CallEXE():void{
			
			//  NativeApplication.nativeApplication   NativeApplication  
			
			// 。
			
			/*  autoExit   true( ) , , 。  exiting   exit  。  autoExit   false,  NativeApplication.nativeApplication.exit()  。*/
			
			NativeApplication.nativeApplication.autoExit=true;
			
			// 
			
			file=file.resolvePath("C:/windows/notepad.exe"); //    C:/windows/notepad.exe
			//file=file.resolvePath("C:/Users/LONMID/Desktop/flex.bat");  //assertThat.doc
			//C:/Program Files/UltraEdit/Uedit32.exe
			trace("file :",file.nativePath);
			
			nativeProcessStartupInfo = new NativeProcessStartupInfo();
			
			nativeProcessStartupInfo.executable = file;
			
			
			//fscommand("exec","D:\\M1\\clockv1.bat");
		}
		
		
		
		public  function runTest():void
			
		{
			
			var process:NativeProcess = new NativeProcess();
			
			process.start(nativeProcessStartupInfo);
			
		}
		
	}
}  2. 다음과 같이 WORD, EXCEL, PPT 파일을 조작합니다.
package com.floor.screen.redevelop.app
{
	import flash.display.Sprite;
	import flash.desktop.NativeProcess;
	import flash.desktop.NativeProcessStartupInfo;
	import flash.events.Event;
	import flash.events.ProgressEvent;
	import flash.events.IOErrorEvent;
	import flash.events.NativeProcessExitEvent;
	import flash.filesystem.File;
	
	public class NativeProcessDemo extends Sprite
	{
		public var process:NativeProcess;
		public function NativeProcessDemo()
		{
			if(NativeProcess.isSupported)
			{
				setupAndLaunch();
			}
			else
			{
				trace("NativeProcess not supported.");
			}
		}
		
		public function setupAndLaunch():void
		{     
			var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
			var file:File = File.applicationDirectory.resolvePath("C:/Program Files/Microsoft Office/Office12/POWERPNT.EXE");  
			//C:/windows/notepad.exe
			//C:/Program Files/UltraEdit/Uedit32.exe
			//C:\Program Files\Microsoft Office\Office12
			//WINWORD.EXE
			
			nativeProcessStartupInfo.executable = file;
			var processArgs:Vector.<String> = new Vector.<String>();
			processArgs[0] = "C:/Users/LONMID/Desktop/Java 1.ppt"
			//"C:/Users/LONMID/Desktop/lamp.doc"; 
			//C:\\Users\\LONMID\\Desktop\\info.txt
			//C:\Users\LONMID\Desktop
			//D:/new/8FloorScreenRedevelop/src/_readme.txt
			//
			
			nativeProcessStartupInfo.arguments = processArgs;
			process = new NativeProcess();
			process.start(nativeProcessStartupInfo);
			process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
			process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, onErrorData);
			process.addEventListener(NativeProcessExitEvent.EXIT, onExit);
			process.addEventListener(IOErrorEvent.STANDARD_OUTPUT_IO_ERROR, onIOError);
			process.addEventListener(IOErrorEvent.STANDARD_ERROR_IO_ERROR, onIOError);
			process.closeInput();
		}
		public function onOutputData(event:ProgressEvent):void
		{
			trace("Got: ", process.standardOutput.readUTFBytes(process.standardOutput.bytesAvailable)); 
		}
		
		public function onErrorData(event:ProgressEvent):void
		{
			trace("ERROR -", process.standardError.readUTFBytes(process.standardError.bytesAvailable)); 
		}
		
		public function onExit(event:NativeProcessExitEvent):void
		{
			if(event.exitCode.toString()=="0")
			{
			//	GameModel.getInstance().state=false;
			}
			else if(event.exitCode.toString()=="1")
			{
			//	GameModel.getInstance().state=true;
			}
			this.dispatchEvent(new Event("refresh"));
		}
		public function onIOError(event:IOErrorEvent):void
		{
			trace(event.toString());
		}
	}
}  다음 두 가지 방법 모두 해당 구성 파일에 추가해야 합니다.
   <supportedProfiles>extendedDesktop</supportedProfiles>  마지막에 포장할 때 또...
Signed AIR 패키지가 아닌 Signed native installer.
3. 다음과 같이 PDF 파일로 작업합니다.
<?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"
					   initialize="initApp();"
					   showStatusBar="false" 
					   width="1558"  
					   height="740" 
					   >
	<fx:Declarations>
		<!--  ( 、 )  -->
	</fx:Declarations>
	<fx:Script>
		<![CDATA[
			import flash.html.HTMLPDFCapability;    //use HTMLPDFCapability
			import flash.html.HTMLLoader;           //use HTMLLoader
			import mx.controls.Alert;               //use Alert
			//initialize
			private function initApp():void
			{
				// 
			 //	this.stage.nativeWindow.startMove();  
			 //this.stage.nativeWindow.alwaysInFront=true;
				
				//check Adobe Reader 8.1 or above capability
				if(HTMLLoader.pdfCapability==HTMLPDFCapability.STATUS_OK)
				{
					var request:URLRequest = new URLRequest("C:/Users/LONMID/Desktop/object-oriented Analysis & Design.pdf");//URLRequest example
					var pdf:HTMLLoader = new HTMLLoader();        //HTML Control
					pdf.height = 800;               //set pdf height
					pdf.width = 1280;                //set pdf width  
					pdf.load(request);              //load pdf
					container.addChild(pdf);        //put pdf in HTML container
				}
				else
					Alert.show("pdf cant display, not Adobe Reader 8.1 and above version");
			}
			private function htmlLoaded(event:Event):void
			{
				
			}  
		]]>
	</fx:Script>
	<mx:HTML id="container" width="1278" height="718"/>
	
</s:WindowedApplication>
  4.html 파일 표시
<?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"
					   width="1280"
					   height="800"	  
				
					   >
	<fx:Declarations>
		<!--  ( 、 )  -->
	</fx:Declarations>
	
	<fx:Script>
		<![CDATA[
			import mx.controls.HTML;
			
			private function onComplete(evt:Event):void {
				
				var document:Object = HTML(evt.currentTarget).htmlLoader.window.document;
				
				var anchors:Object = document.getElementsByTagName("a");
				
				if(anchors != null) { //    :http://hi.baidu.com/taotao5453
					
					for(var i:Number=0; i < anchors.length; i++) {
						
						anchors[i].onmouseup = function():void {
							
							var request:URLRequest = new URLRequest(arguments[0].srcElement);
							
							navigateToURL(request,"_blank");
							
						}
						
					}
				}
			}
					
		]]>
	</fx:Script>
	
	<mx:Panel width="95%" height="98%" layout="absolute" horizontalCenter="0">
		<mx:HTML id="content" width="100%" location="http://www.baidu.com" height="90%"
				          complete="onComplete(event)" top="70" horizontalCenter="0"/>
	</mx:Panel>
	
</s:WindowedApplication>
  결론: 필자는 Flex, AIR가 로컬 파일을 조작하는 방법의 총결을 실현하고 현지화 작업에 도움이 필요하다.행운을 빌어요!!!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다른 사람의 웹사이트 편집: contenteditable 및 designMode그래도 우리가 그렇게 할 수 있다고 생각하는 것은 멋진 일입니다. 제가 강조하고 싶었던 일종의 관련 API가 실제로 몇 개 있기 때문에 오늘 그것을 가져왔습니다. contenteditable는 "true" 값이 할당...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.