0 Replies Latest reply on Jul 19, 2010 3:22 AM by Prashant@Mdocs

    want ProgressBar During Zip File Extraction?

    Prashant@Mdocs

      i have develop a application

      ,in which zip file is extracted

      .(unzipping a zip file),but i want to show progressbar during zip file extract process,i have tried but i am unable to do that.........plz help me?here is my code.......

      ====================

      mxml file->

      <?xml version="1.0" encoding="utf-8"?>

      <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="initApp()">

       

      <mx:Script>

      <![CDATA[

      import com.kfc.repflex.utils.ZipExtractComponent;

      import mx.controls.Alert;

      [Bindable]

      private var zip:ZipExtractComponent = null;

      private function initApp():void{

      zip = new ZipExtractComponent("C:/AdobeAIRInstaller.zip");

      }

       

       

      ]]>

      </mx:Script>

       

      <mx:Panel title="Load and extract ZIP files" layout="vertical" horizontalCenter="0" verticalCenter="0" horizontalAlign="center" verticalAlign="middle">

      <mx:Button id="load" label="Load and Extract ZIP" click="zip.loadZIP()"/>

      </mx:Panel>

       

       

      </mx:WindowedApplication>

       

      ====================================

      action script class->

      package com.amdocs.repflex.utils

      {

      import com.amdocs.repflex.utils.zip.*;

       

      import flash.events.EventDispatcher;

      import flash.filesystem.*;

       

      import mx.controls.Alert;

       

       

      public class ZipExtractComponent extends EventDispatcher

      {

       

      private var zipInput:File = new File();

      private var zipOutput:File = new File();

      private var zipFile:ZipFile=null;

      private var fileIn:String;

      private var fileOut:String;

      public function ZipExtractComponent(fIn:String){

      this.fileIn=fIn;

      //this.fileOut=fout;

      }

       

      public function loadZIP():void

      {

      zipInput.nativePath=fileIn;

      var stream:FileStream = new FileStream();

      stream.open(zipInput,FileMode.READ);

      zipFile = new ZipFile(stream);

      extractZip();

      }

      public function extractZip():void

      {

      for(var i:uint = 0; i<zipFile.entries.length; i++)

      {

      var zipEntry:ZipEntry = zipFile.entries[i] as ZipEntry;

      if(!zipEntry.isDirectory())

      {

      //zipOutput.nativePath=fileOut;

      //var targetDir:File = new File("C:/Documents and Settings");

      var targetDir:File = File.documentsDirectory.resolvePath("");

       

      var entryFile:File = new File();

      entryFile = targetDir.resolvePath(zipEntry.name);

      var entry:FileStream = new FileStream();

      entry.open(entryFile, FileMode.WRITE);

      entry.writeBytes(zipFile.getInput(zipEntry));

      entry.close();

      }

      }

      Alert.show("EXTRACTED SUCCESSFULLY");

      }

       

       

      }

      }