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

    Handling embedded file.


      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?

      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"
      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{

      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);

      public function fileCompleteHandler(e:FZipEvent):void{
      var file:FZipFile = e.file;
      trace("File loaded: "+ file.filename);

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