/** * VERSION: 1.84 * DATE: 2011-03-23 * AS3 * UPDATES AND DOCS AT: http://www.greensock.com/loadermax/ **/ package com.greensock.loading { import flash.events.Event; /** * Loads generic binary data - identical to using a DataLoader with its "format" * special property set to "binary". The reason for having a BinaryDataLoader * class is to allow certain file extensions (like ".zip") to be associated with it so that the * LoaderMax.parse() method can accurately parse URLs with those file extensions. If you do * not plan on using the LoaderMax.parse() method, however, you could save a small amount * of kb by simply using DataLoaders with their format set to "binary" instead of using BinaryDataLoaders.

* * The following are essentially the same:
* new DataLoader("file.zip", {format:"binary"});
* new BinaryDataLoader("file.zip");


* * If you'd like to associate additional file extensions with BinaryDataLoader, you may use the * LoaderMax.registerFileType() method.

* * OPTIONAL VARS PROPERTIES
* The following special properties can be passed into the BinaryDataLoader constructor via its vars * parameter which can be either a generic object or a DataLoaderVars object:
*
* * Note: Using a DataLoaderVars instance * instead of a generic object to define your vars is a bit more verbose but provides * code hinting and improved debugging because it enforces strict data typing. Use whichever one you prefer.

* * @example Example AS3 code: import com.greensock.loading.~~; import com.greensock.events.LoaderEvent; //create a BinaryDataLoader var loader:BinaryDataLoader = new BinaryDataLoader("file.zip", {name:"myZipFile", requireWithRoot:this.root, estimatedBytes:6800}); //begin loading loader.load(); //or we could parse() and array of files, creating a LoaderMax queue with loaders for each file. To do that, we'll first create the array: var files:Array = ["files/archive.zip","images/1.jpg","files/report.pdf","swfs/child.swf"]; //since we want the parse() method to recognize the .pdf file as a BinaryDataLoader, we should registerFileType() first because pdf isn't one of the extensions recognized by default. LoaderMax.registerFileType("pdf", BinaryDataLoader); //before we parse() the array, we need to activate() the loader types that LoaderMax should recognize (we only need to do this once) LoaderMax.activate([BinaryDataLoader, ImageLoader, SWFLoader]); //now parse the files and create a LoaderMax queue var queue:LoaderMax = LoaderMax.parse(files, {onProgress:progressHandler, onComplete:completeHandler, onChildFail:childFailHandler}); queue.load(); function progressHandler(event:LoaderEvent):void { trace("progress: " + event.target.progress); } function completeHandler(event:LoaderEvent):void { trace("completed " + event.target); } function childFailHandler(event:LoaderEvent):void { trace(event.target + " failed."); } * * Copyright 2011, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. * * @see com.greensock.loading.data.DataLoaderVars * * @author Jack Doyle, jack@greensock.com */ public class BinaryDataLoader extends DataLoader { /** @private **/ private static var _classActivated:Boolean = _activateClass("BinaryDataLoader", BinaryDataLoader, "zip"); /** * Constructor * * @param urlOrRequest The url (String) or URLRequest from which the loader should get its content. * @param vars An object containing optional configuration details. For example: new BinaryDataLoader("file.zip", {name:"myZipFile", onComplete:completeHandler, onProgress:progressHandler}).

* * The following special properties can be passed into the constructor via the vars parameter * which can be either a generic object or a DataLoaderVars object:
* * @see com.greensock.loading.data.DataLoaderVars */ public function BinaryDataLoader(urlOrRequest:*, vars:Object=null) { super(urlOrRequest, vars); _loader.dataFormat = "binary"; //just to make sure it wasn't overridden if the "format" special vars property was passed into in DataLoader's constructor. _type = "BinaryDataLoader"; } } }