| Package | deng.fzip |
| Class | public class FZipLibrary |
| Inheritance | FZipLibrary 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
| Method | Defined by | ||
|---|---|---|---|
|
Constructor
| FZipLibrary | ||
|
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 | ||
| Event | Summary | Defined by | ||
|---|---|---|---|---|
| Dispatched when all pending files have been processed. | FZipLibrary | |||
| FZipLibrary | () | constructor |
public function FZipLibrary()Constructor
| addZip | () | method |
public function addZip(zip:FZip):voidUse 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.
Parameterszip:FZip — An FZip instance to process
|
| formatAsBitmapData | () | method |
public function formatAsBitmapData(ext:String):voidUsed to indicate a file extension that triggers formatting to BitmapData.
Parametersext:String — A file extension (".jpg", ".png", etc)
|
| formatAsDisplayObject | () | method |
public function formatAsDisplayObject(ext:String):voidUsed to indicate a file extension that triggers formatting to DisplayObject.
Parametersext:String — A file extension (".swf", ".png", etc)
|
| getBitmapData | () | method |
public function getBitmapData(filename:String):BitmapDataRequest a file that has been formatted as BitmapData. A ReferenceError is thrown if the file does not exist as a BitmapData.
Parametersfilename:String — The filename of the BitmapData instance.
|
BitmapData |
| getDefinition | () | method |
public function getDefinition(filename:String, definition:String):ObjectRetrieve 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.
Parametersfilename:String — The filename of the DisplayObject instance.
|
|
definition:String |
Object |
| getDisplayObject | () | method |
public function getDisplayObject(filename:String):DisplayObjectRequest a file that has been formatted as a DisplayObject. A ReferenceError is thrown if the file does not exist as a DisplayObject.
Parametersfilename:String — The filename of the DisplayObject instance.
|
DisplayObject |
| complete | event |