<?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[
private var nativeProcess:NativeProcess;
private function onGo() : void {
outputField.text = "";
var file:File = new File("C:\\Program Files (x86)\\Java\\jdk1.6.0_18\\bin\\java.exe");
var descriptorFile:File = new File("C:\\AirPackageApp-app.xml");
var swfFile:File = new File("C:\\AirPackageApp.swf");
var processArgs:Vector.<String> = new Vector.<String>;
processArgs.push("-jar");
processArgs.push("C:\\adt.jar");
processArgs.push("-checkstore");
processArgs.push("-storetype");
processArgs.push("pkcs12");
processArgs.push("-keystore");
processArgs.push("-storepass");
processArgs.push("sybrant");
processArgs.push("c:\\nodename.air");
processArgs.push(descriptorFile.nativePath);
processArgs.push(swfFile.nativePath);
var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
nativeProcessStartupInfo.arguments = processArgs;
nativeProcessStartupInfo.executable = file;
nativeProcess = new NativeProcess();
nativeProcess.addEventListener(ProgressEvent.STANDARD_ERROR_DATA,onCertErrOutputData);
nativeProcess.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA,onCertOutputData);
nativeProcess.start(nativeProcessStartupInfo);
}
private function onCertErrOutputData(event:ProgressEvent) : void {
var certResponse:String = new String();
certResponse = nativeProcess.standardError.readUTFBytes(nativeProcess.standardError.bytesAvailable);
trace(certResponse);
outputField.text += certResponse;
if (certResponse.substr(0,5) == "valid") {
trace("Correct password!");
nativeProcess.removeEventListener(ProgressEvent.STANDARD_ERROR_DATA,onCertOutputData);
nativeProcess.exit();
} else {
trace("Incorrect password! Error...");
nativeProcess.removeEventListener(ProgressEvent.STANDARD_ERROR_DATA,onCertOutputData);
nativeProcess.exit();
}
}
protected function onCertOutputData(event:ProgressEvent):void
{
trace(nativeProcess.standardOutput.readUTFBytes(nativeProcess.standardOutput.bytesAvailable));
}
]]>
</fx:Script>
<s:layout>
<s:VerticalLayout/>
</s:layout>
<s:Button label="go" click="onGo()" />
<s:TextInput id="passField"/>
<s:TextArea id="outputField" width="100%" height="100%"/>
Comment créer un fichier .air via Adt.jar à l'aide de NativeProcess dans Adobe AIR?
Il fonctionne tout va bien quand on travaille avec commande prompt.It générer un fichier nodename.air dans C: \ nodename.air. Mais lorsque vous utilisez processus natif cela fonctionne jusqu'à arguments suivants
processArgs.push("-storepass");
processArgs.push("sybrant");
Après que si je missspelled mon dossier air descriptor.xml ou mon fichier swf ne jette pas msg d'erreur, mais il jette une erreur dans l'invite de commande. (OS Windows 7, la version Java 1.6)
Merci, de Raja.J