1 Reply Latest reply on Mar 28, 2008 8:27 AM by slaingod

    Handling embedded file.

    nonbut

      What I did :

      - I embedded a ZIP file("ABC.zip") in my SWF file.

      What I want to do :

      - I want to use the embedded ZIP file like a real file
      so that I can decompress the file.
      How can I REFER to the embedded file?



      Here,
      var request:URLRequest = new URLRequest(String(zip));
      URLRequest class needs the exact pointer of the ZIP file.



      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      creationComplete="doIt()">
      <mx:Script>
      <![CDATA[
      import mx.core.ByteArrayAsset;
      import deng.fzip.*;

      use namespace deng.fzip.FZip;
      use namespace deng.fzip.FZipFile;
      use namespace deng.fzip.FZipEvent;

      [Embed(source="ABC.zip", mimeType="application/octet-stream")]
      private static const ClaZipFile:Class;

      public function doIt():void{
      getZip();
      }

      public function getZip():void{
      //Make ByteArrayAsset by ClaZipFile that was made by the embedded file.
      var ba:ByteArrayAsset = ByteArrayAsset( new ClaZipFile() );

      var zip:FZip = new FZip(ba.readUTFBytes( ba.length ));
      trace(zip); //[object FZip]
      var request:URLRequest = new URLRequest(String(zip)); //<-- How can I refer to the embedded file?
      zip.addEventListener(FZipEvent.FILE_LOADED, fileCompleteHandler);
      zip.load(request);
      }

      public function fileCompleteHandler(e:FZipEvent):void{
      var file:FZipFile = e.file;
      trace("File loaded: "+ file.filename);
      }
      ]]>
      </mx:Script>
      </mx:Application>




      // You will need to use FZip class to test my program. These are the samples and Sources.

      http://ntt.cc/2008/01/19/actionscript-class-library-fzip.html#more-39

      http://www.flexcoders.cn/data/flexResource/fzip/FZipTest.html