Skip to content

Commit

Permalink
Small identantion cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Debert committed Sep 7, 2009
1 parent 3e99e3d commit 75266d1
Show file tree
Hide file tree
Showing 4 changed files with 271 additions and 262 deletions.
76 changes: 41 additions & 35 deletions src/br/com/stimuli/loading/BulkLoader.as
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,18 @@ import flash.utils.*;
* The name of the event
* @eventType progress
*/
public static const PROGRESS : String = "progress";
public static const PROGRESS : String = "progress";
/**
* The name of the event
* @eventType complete
*/
public static const COMPLETE : String = "complete";
public static const COMPLETE : String = "complete";

/**
* The name of the event
* @eventType httpStatus
*/
public static const HTTP_STATUS : String = "httpStatus";
public static const HTTP_STATUS : String = "httpStatus";

/**
* The name of the event
Expand Down Expand Up @@ -205,31 +205,31 @@ import flash.utils.*;
public static const CHECK_POLICY_FILE : String = "checkPolicyFile"


// properties on adding a new url:
/** If <code>true</code> a random query (or post data parameter) will be added to prevent caching. Checked when adding a new item to load.
* @see #add()
*/
public static const PREVENT_CACHING : String = "preventCache";
/** An array of RequestHeader objects to be used when contructing the <code>URLRequest</code> object. If the <code>url</code> parameter is passed as a <code>URLRequest</code> object it will be ignored. Checked when adding a new item to load.
* @see #add()
*/
public static const HEADERS : String = "headers";
/** An object definig the loading context for this load operario. If this item is of <code>TYPE_SOUND</code>, a <code>SoundLoaderContext</code> is expected. If it's a <code>TYPE_IMAGE</code> a LoaderContext should be passed. Checked when adding a new item to load.
* @see #add()
*/
public static const CONTEXT : String = "context";
/** A <code>String</code> to be used to identify an item to load, can be used in any method that fetches content (as the key parameters), stops, removes and resume items. Checked when adding a new item to load.
* @see #add()
* @see #getContent()
* @see #pause()
* @see #resume()
* @see #removeItem()
*/
public static const ID : String = "id";
// properties on adding a new url:
/** If <code>true</code> a random query (or post data parameter) will be added to prevent caching. Checked when adding a new item to load.
* @see #add()
*/
public static const PREVENT_CACHING : String = "preventCache";
/** An array of RequestHeader objects to be used when contructing the <code>URLRequest</code> object. If the <code>url</code> parameter is passed as a <code>URLRequest</code> object it will be ignored. Checked when adding a new item to load.
* @see #add()
*/
public static const HEADERS : String = "headers";
/** An object definig the loading context for this load operario. If this item is of <code>TYPE_SOUND</code>, a <code>SoundLoaderContext</code> is expected. If it's a <code>TYPE_IMAGE</code> a LoaderContext should be passed. Checked when adding a new item to load.
* @see #add()
*/
public static const CONTEXT : String = "context";
/** A <code>String</code> to be used to identify an item to load, can be used in any method that fetches content (as the key parameters), stops, removes and resume items. Checked when adding a new item to load.
* @see #add()
* @see #getContent()
* @see #pause()
* @see #resume()
* @see #removeItem()
*/
public static const ID : String = "id";

/** An <code>int</code> that controls which items are loaded first. Items with a higher <code>PRIORITY</code> will load first. If more than one item has the same <code>PRIORITY</code> number, the order in which they are added will be taken into consideration. Checked when adding a new item to load.
* @see #add()
*/
/** An <code>int</code> that controls which items are loaded first. Items with a higher <code>PRIORITY</code> will load first. If more than one item has the same <code>PRIORITY</code> number, the order in which they are added will be taken into consideration. Checked when adding a new item to load.
* @see #add()
*/
public static const PRIORITY : String = "priority";

/** The number, as an <code>int</code>, to retry downloading an item in case it fails. Checked when adding a new item to load.
Expand Down Expand Up @@ -371,6 +371,7 @@ import flash.utils.*;
text: URLItem,
binary: BinaryItem
}

/** Creates a new BulkLoader object identifiable by the <code>name</code> parameter. The <code>name</code> parameter must be unique, else an Error will be thrown.
*
* @param name A name that can be used later to reference this loader in a static context,
Expand Down Expand Up @@ -413,6 +414,7 @@ import flash.utils.*;
public static function getUniqueName() : String{
return "BulkLoader-" + _instancesCreated;
}

/** Fetched a <code>BulkLoader</code> object created with the <code>name</code> parameter.
* This is usefull if you must access loades assets from another scope, without having to pass direct references to this loader.
* @param name The name of the loader to be fetched.
Expand Down Expand Up @@ -440,7 +442,7 @@ import flash.utils.*;
public function hasItem(key : *, searchAll : Boolean = true) : Boolean{
var loaders : *;
if (searchAll){
loaders = _allLoaders;
loaders = _allLoaders;
}else{
loaders = [this];
}
Expand Down Expand Up @@ -712,6 +714,7 @@ bulkLoader.start(3)
var toRemove : LoadingItem = LoadingItem(itemsToLoad[0]);
return toRemove;
}

/** Register a new file extension to be loaded as a given type. This is used both in the guessing of types from the url and affects how loading is done for each type.
* If you are adding an extension to be of a type you are creating, you must pass the <code>withClass</code> parameter, which should be a class that extends LoadingItem.
* @param extension The file extension to be used (can include the dot or not)
Expand Down Expand Up @@ -785,6 +788,7 @@ bulkLoader.start(3)
}
return null;
}

// if toLoad is specified it will take precedence over whoever is queued cut line
/** @private */
public function _loadNext(toLoad : LoadingItem = null) : Boolean{
Expand Down Expand Up @@ -940,6 +944,7 @@ bulkLoader.start(3)
if (_getNumConnectionsForItem(item) >= maxConnectionsPerHost) return false;
return true;
}

/** @private */
public function _onItemError(evt : ErrorEvent) : void{
var item : LoadingItem = evt.target as LoadingItem;
Expand All @@ -950,8 +955,6 @@ bulkLoader.start(3)
//evt.stopPropagation();
//evt.currentTarget = item;
dispatchEvent(evt);


}


Expand Down Expand Up @@ -1032,6 +1035,7 @@ bulkLoader.start(3)
public function get numConnections() : int {
return _numConnections;
}

/** Returns an object where the urls are the keys(as strings) and the loaded contents are the value for that key.
* Each value is typed as * an the client must check for the right typing.
* @return An object hashed by urls, where values are the downloaded content type of each url. The user mut cast as apropriate.
Expand All @@ -1049,14 +1053,15 @@ bulkLoader.start(3)
}

/**
* The name by which this loader instance can be identified.
* This property is used so you can get a reference to this instance from other classes in your code without having to save and pass it yourself, throught the static method BulkLoader.getLoader(name) .<p/>
* Each name should be unique, as instantiating a BulkLoader with a name already taken will throw an error.
* @see #getLoaders()
*/
* The name by which this loader instance can be identified.
* This property is used so you can get a reference to this instance from other classes in your code without having to save and pass it yourself, throught the static method BulkLoader.getLoader(name) .<p/>
* Each name should be unique, as instantiating a BulkLoader with a name already taken will throw an error.
* @see #getLoaders()
*/
public function get name() : String {
return _name;
}

/**
* The ratio (0->1) of items to load / items total.
* This number is always reliable.
Expand Down Expand Up @@ -1899,6 +1904,7 @@ bulkLoader.start(3)
This is here only to assure that non hadled errors won't bubble up.
*/
public function _swallowError(e:Event):void{}

/** @private */
public static function __debug_print_loaders() : void{
var theNames : Array = []
Expand Down
48 changes: 24 additions & 24 deletions src/br/com/stimuli/loading/loadingtypes/BinaryItem.as
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
package br.com.stimuli.loading.loadingtypes {

import br.com.stimuli.loading.loadingtypes.LoadingItem;
import br.com.stimuli.loading.BulkLoader;
import flash.display.*;
import br.com.stimuli.loading.loadingtypes.LoadingItem;
import br.com.stimuli.loading.BulkLoader;
import flash.display.*;
import flash.net.*;
import flash.events.*;
import flash.utils.*;

/** @private */
public class BinaryItem extends LoadingItem {
public class BinaryItem extends LoadingItem {
public var loader : URLLoader;
public function BinaryItem(url : URLRequest, type : String, uid : String){
super(url, type, uid);
}
override public function _parseOptions(props : Object) : Array{

public function BinaryItem(url : URLRequest, type : String, uid : String){
super(url, type, uid);
}

override public function _parseOptions(props : Object) : Array{
return super._parseOptions(props);
}
override public function load() : void{
super.load();
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.BINARY;
loader.addEventListener(ProgressEvent.PROGRESS, onProgressHandler, false, 0, true);

override public function load() : void{
super.load();
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.BINARY;
loader.addEventListener(ProgressEvent.PROGRESS, onProgressHandler, false, 0, true);
loader.addEventListener(Event.COMPLETE, onCompleteHandler, false, 0, true);
loader.addEventListener(IOErrorEvent.IO_ERROR, onErrorHandler, false, 0, true);
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, super.onHttpStatusHandler, false, 0, true);
loader.addEventListener(Event.OPEN, onStartedHandler, false, 0, true);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, super.onSecurityErrorHandler, false, 0, true);
try{
// TODO: test for security error thown.
loader.load(url);
// TODO: test for security error thown.
loader.load(url);
}catch( e : SecurityError){
onSecurityErrorHandler(_createErrorEvent(e));
onSecurityErrorHandler(_createErrorEvent(e));

}
};
override public function onErrorHandler(evt : ErrorEvent) : void {
super.onErrorHandler(evt);
};

override public function onErrorHandler(evt : ErrorEvent) : void {
super.onErrorHandler(evt);
}

override public function onStartedHandler(evt : Event) : void{
Expand Down
Loading

0 comments on commit 75266d1

Please sign in to comment.