Packagedeng.fzip
Classpublic class FZipLibrary
InheritanceFZipLibrary Inheritance flash.events.EventDispatcher

FZipLibrary works with a FZip instance to load files as usable instances, like a DisplayObject or BitmapData. Each file from a loaded zip is processed based on their file extentions. More than one FZip instance can be supplied, and if it is currently loading files, then FZipLibrary will wait for incoming files before it completes.

Flash's built-in Loader class is used to convert formats, so the only formats currently supported are ones that Loader supports. As of this writing they are SWF, JPEG, GIF, and PNG.

The following example loads an external zip file, outputs the width and height of an image and then loads a sound from a SWF file.

  package {
   import flash.events.
   import flash.display.BitmapData;
   import deng.fzip.FZip;
   import deng.fzip.FZipLibrary;
   
   public class Example {
    private var lib:FZipLibrary;
    
    public function Example(url:String) {
     lib = new FZipLibrary();
     lib.formatAsBitmapData(".gif");
     lib.formatAsBitmapData(".jpg");
     lib.formatAsBitmapData(".png");
     lib.formatAsDisplayObject(".swf");
     lib.addEventListener(Event.COMPLETE,onLoad);
     
     var zip:FZip = new FZip();
     zip.load(url);
     lib.addZip(zip);
    }
    private function onLoad(evt:Event) {
     var image:BitmapData = lib.getBitmapData("test.png");
     trace("Size: " + image.width + "x" + image.height);
     
     var importedSound:Class = lib.getDefinition("data.swf", "SoundClass") as Class;
     var snd:Sound = new importedSound() as Sound;
    }
   }
  }

See also

http://livedocs.macromedia.com/flex/201/langref/flash/display/Loader.html


Public Methods
 MethodDefined by
  
Constructor
FZipLibrary
  
addZip(zip:FZip):void
Use this method to add an FZip instance to the processing queue.
FZipLibrary
  
formatAsBitmapData(ext:String):void
Used to indicate a file extension that triggers formatting to BitmapData.
FZipLibrary
  
formatAsDisplayObject(ext:String):void
Used to indicate a file extension that triggers formatting to DisplayObject.
FZipLibrary
  
getBitmapData(filename:String):BitmapData
Request a file that has been formatted as BitmapData.
FZipLibrary
  
getDefinition(filename:String, definition:String):Object
Retrieve a definition (like a class) from a SWF file that has been formatted as a DisplayObject.
FZipLibrary
  
getDisplayObject(filename:String):DisplayObject
Request a file that has been formatted as a DisplayObject.
FZipLibrary
Events
 EventSummaryDefined by
   Dispatched when all pending files have been processed.FZipLibrary
Constructor detail
FZipLibrary()constructor
public function FZipLibrary()

Constructor

Method detail
addZip()method
public function addZip(zip:FZip):void

Use this method to add an FZip instance to the processing queue. If the FZip instance specified is not active (currently receiving files) when it is processed than only the files already loaded will be processed.

Parameters
zip:FZip — An FZip instance to process
formatAsBitmapData()method 
public function formatAsBitmapData(ext:String):void

Used to indicate a file extension that triggers formatting to BitmapData.

Parameters
ext:String — A file extension (".jpg", ".png", etc)
formatAsDisplayObject()method 
public function formatAsDisplayObject(ext:String):void

Used to indicate a file extension that triggers formatting to DisplayObject.

Parameters
ext:String — A file extension (".swf", ".png", etc)
getBitmapData()method 
public function getBitmapData(filename:String):BitmapData

Request a file that has been formatted as BitmapData. A ReferenceError is thrown if the file does not exist as a BitmapData.

Parameters
filename:String — The filename of the BitmapData instance.

Returns
BitmapData
getDefinition()method 
public function getDefinition(filename:String, definition:String):Object

Retrieve a definition (like a class) from a SWF file that has been formatted as a DisplayObject. A ReferenceError is thrown if the file does not exist as a DisplayObject, or the definition does not exist.

Parameters
filename:String — The filename of the DisplayObject instance.
 
definition:String

Returns
Object
getDisplayObject()method 
public function getDisplayObject(filename:String):DisplayObject

Request a file that has been formatted as a DisplayObject. A ReferenceError is thrown if the file does not exist as a DisplayObject.

Parameters
filename:String — The filename of the DisplayObject instance.

Returns
DisplayObject
Event detail
completeevent 
Event object type: flash.events.Event

Dispatched when all pending files have been processed.