Actionscript 3 如何在actionscript中使用base64编码解压文件?

Actionscript 3 如何在actionscript中使用base64编码解压文件?,actionscript-3,flash-builder,Actionscript 3,Flash Builder,我在解压combobox中的.zip文件时遇到问题。我选择了1.zip文件,在选择了特定的.zip文件按钮后,应该解压它并将内容放入另一个combobox中。有人能帮我吗 下面是一个代码: // ActionScript file import flash.display.*; import flash.events.*; import flash.utils.ByteArray; import com.Base64; import mx

我在解压combobox中的.zip文件时遇到问题。我选择了1.zip文件,在选择了特定的.zip文件按钮后,应该解压它并将内容放入另一个combobox中。有人能帮我吗

下面是一个代码:

    // ActionScript file
     import flash.display.*;
     import flash.events.*;
     import flash.utils.ByteArray;
     import com.Base64;
     import mx.controls.Alert;

     [Bindable] private var sfile:FileReference;
     [Bindable] private var zipdataProvdr:ArrayCollection = new ArrayCollection([{label:        "test", file: "test"},{label: "elm34001", file: "elm34001"}, {label: "elm34003", file: "elm34003"}, {label: "elm34005", file: "elm34005"}, {label: "elm34009", file: "elm34009"},{label: "elm34011", file: "elm34011"}, {label: "elm34013", file: "elm34013"}]);
      //private var zip:FZip;
      //private var flag:Boolean;


       private function init(event:Event):void
       {
         var file:ByteArray = new ByteArray();
         file = "test.zip";
         var encode:String = Base64.encodeByteArray(file);
         Alert.show("Encoded file is " + encode);
         for (var i:int = 0; i < zipdataProvdr.length; i++)
         { 
        file = zipdataProvdr[i];
        Alert.show("file is " + file);
         }
        //var encoded:String = Base64.encodeByteArray(file);
         //Alert.show("encoded file is " + encoded.toString());


       }
//ActionScript文件
导入flash.display.*;
导入flash.events.*;
导入flash.utils.ByteArray;
导入com.Base64;
导入mx.controls.Alert;
[Bindable]私有变量文件:FileReference;
[Bindable]private var zipdataProvdr:ArrayCollection=new ArrayCollection([{label:“test”,file:“test”},{label:“elm34001”,file:“elm34003”,file:“elm34003”},{label:“elm34009”,file:“elm34009”},{label:“elm34011”,file:“elm34011”},{label:“elm34013”,file:“elm34013”});
//私有var-zip:FZip;
//私有变量标志:布尔值;
私有函数init(事件:event):void
{
var文件:ByteArray=newbytearray();
file=“test.zip”;
var encode:String=Base64.encodeByteArray(文件);
显示(“编码文件为”+编码);
对于(变量i:int=0;i
我不确定你能不能。不过,无需重新发明轮子,可以尝试使用类似于此的zip库:

我使用Nochump lib解压文件。代码如下:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()"         layout="absolute">
    <mx:Script>
        <![CDATA[
          import flash.net.URLStream;
          import flash.net.URLRequest;
          import mx.controls.Alert;
          import mx.collections.ArrayCollection;
          import flash.events.Event;
          import flash.events.ErrorEvent;
          import flash.events.ProgressEvent;
          import nochump.util.zip.ZipFile;


          [Bindable] private var _files:Array = ["/MyMapFolder/elm34001.zip", "/MyMapFolder/elm34003.zip", "/MyMapFolder/elm34005.zip", "/MyMapFolder/elm34009.zip", "/MyMapFolder/elm34011.zip", "/MyMapFolder/elm34013.zip"];
          private var zpfls:ZipFile;
          [Bindable] private var arr:Array;
          private var arrcoll:ArrayCollection;

          private function loadZipFile():void {
            currentState = "loading";
            var urlStream:URLStream = new URLStream();
            loadProgress.source = urlStream;
            urlStream.addEventListener(Event.COMPLETE,completeHandler);
            urlStream.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
               //urlStream.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler);
            urlStream.load(new   URLRequest(String(cbFiles.selectedItem)));
            //Alert.show("Testing........" + urlStream.endian);
            //Alert.show("Testing........" + urlStream.objectEncoding);
            //Alert.show("Testing........" + urlStream);
        }

        private function completeHandler(event:Event):void 
        {
            var data:URLStream = URLStream(event.target);
            arr = new Array();
            //Alert.show("***Length of file is " + data.bytesAvailable);
            zpfls = new ZipFile(data);
            arr = new Array(zpfls.entries[1]);
            Alert.show("Show only Shape File: " + arr);
        }

        private function errorHandler(event:ErrorEvent):void {
            currentState = "error";
            errorLabel.text = event.text;
        }

    ]]>
   </mx:Script>
   <mx:states>
       <mx:State name="loading">
           <mx:AddChild relativeTo="{this}" position="lastChild">
            <mx:ProgressBar id="loadProgress" width="100%" />
           </mx:AddChild>           
       </mx:State>
       <mx:State name="error">
        <mx:AddChild relativeTo="{this}" position="lastChild">
            <mx:Label id="errorLabel" />
        </mx:AddChild>
       </mx:State>
   </mx:states>

   <mx:Label text="Select a zip file and click &quot;Load&quot;."  x="67" y="10"/>
   <mx:ComboBox id="cbFiles" dataProvider="{_files}" width="300"  x="10" y="36"/>
   <mx:Button label="Load" click="loadZipFile()"  x="333" y="36"/>
   <mx:ComboBox x="394" y="36" id="cbobxs" dataProvider="{arr}" width="169">            </mx:ComboBox> 

       </mx:Application>


您能展示一些您当前正在做的事情的代码吗?您卡在哪里了?以上是代码,我无法将zip文件分配给bytearray变量?感谢您的帮助citizen conn!如何在计算机上下载解压后的文件?