6 Replies Latest reply on Jul 25, 2012 2:34 AM by Vejko

    NativeProcess progressevent doesn't get dispatched


      Hi guys,


      I have a simple nativeprocess code in my app. I unzip password protected zip files using 7zip and want to capture every time a file is unzipped.


      Here's the code:


                          var npInfo:* = new NativeProcessStartupInfo();


                          npInfo.executable = app_7za;       


                           var args:Vector.<String> = new Vector.<String>;           








                          npInfo.arguments = args; 


                          processBuffer = new ByteArray();

                          nativeProcess = new NativeProcess();


                          nativeProcess.addEventListener("standardOutputData",         onStandardOutputData);

                          nativeProcess.addEventListener("standardInputProgress",     onStandardOutputProgress);

                          nativeProcess.addEventListener(NativeProcessExitEvent.EXIT, onStandardOutputClose);


                          nativeProcess.addEventListener("standardErrorData",            onIOError);           

                          nativeProcess.addEventListener("standardOutputIoError",      onIOError);

                          nativeProcess.addEventListener("standardErrorIoError",         onIOError);

                          nativeProcess.addEventListener("standardInputIoError",         onIOError);  


      When I use it, it works, but I can only see the final output and the standardOutputData event doesn't get dispatched during the process.


      Do you guys have any idea?


      Thanks in advance.



        • 1. Re: NativeProcess progressevent doesn't get dispatched

          Thats because output data is used when the executable returns some sort of output stream.

          You can listen on the exit event, which will fire as your process is complete (note: it'll only fire once all the files have extracted, you'd have to do them indvidually to capture each extraction within flash)


          private function onExit( event:NativeProcessExitEvent ):void {

                      trace("Native Process Exit code: " + event.exitCode);



          And you'll get one of these exit codes


          Exit Codes from 7-Zip

          7-Zip returns the following exit codes:

          0No error
          1Warning (Non fatal error(s)). For example, one or more files were locked by some other application, so they were not compressed.
          2Fatal error
          7Command line error
          8Not enough memory for operation
          255User stopped the process
          • 2. Re: NativeProcess progressevent doesn't get dispatched
            Vejko Level 1

            Thanks for your answer, but I think I need some kind of StandardOutputProgress Event, which unfortunatelly doesn't exist.


            I start the extract process and during extraction I would like to listen to the output to get the filename once 7zip extracted a file.


            It's like if you run a ping command in terminal or command line, you would like to get all the outputs real time, not  just all of them together on Exit.

            • 3. Re: NativeProcess progressevent doesn't get dispatched
              Bambii7 Level 1

              You could use the air File class to periodically read the directory file.getDirectoryListing()

              Why do you need real time? How many files are in there? 7zip is pretty fast. While you're waiting for the exit code, you could set an interval to read the directory every 500ms.

              • 4. Re: NativeProcess progressevent doesn't get dispatched
                Vejko Level 1

                My Air app installs files from a password protected zip files which is pretty big (700mb) it has many video files in it and it would be a good thing to show the progress to the user.


                The zip file is on a DVD and that makes it even slower. It's not the best user experience to see "Please wait..." without seeing the real progress.


                Yes, I can get a list from 7zip what's in the zip file and using the File class' exists property check whether it's copied but it is a dirty hack.

                • 5. Re: NativeProcess progressevent doesn't get dispatched
                  Bambii7 Level 1

                  By install do you mean read into flash? Or actually transfer to users machine?

                  You could write a shell script that will interact with 7za, extract the files one by one and output the progress.

                  I'm reading and wrting files into a zip, and storing a config file in there which keeps info about the zip contents. Then I know I can extract that conf and loop through all the files one by one reading them into flash.

                  • 6. Re: NativeProcess progressevent doesn't get dispatched
                    Vejko Level 1

                    I extract the files to the ApplicationStorageDirectory, so I have to save the files.


                    If you use 7zip, you don't have to have additional config file. 7zip can give you a list of the files inside the zip file without extracting them. It's very handy.


                    Your solution works, and that's one workaround. I thought that there is an event unkonwn by me and that way It's just one more line and I don't have to run my nativeProcess 200 times to extract 200 files.


                    Thanks for your help again, I appriciate it.