GroupLoad

Kind of class:public class
Package:org.casalib.load
Inherits from:ProcessGroup < Process < RemovableEventDispatcher < EventDispatcher
Version:01/20/09
Author:Aaron Clinger
Classpath:org.casalib.load.GroupLoad
File last modified:Tuesday, 20 January 2009, 16:37:53
Allows multiple loads to be grouped and treated as one larger load.
Example:
  • package {
        import flash.display.MovieClip;
        import org.casalib.load.GraphicLoad;
        import org.casalib.load.GroupLoad;
        import org.casalib.events.LoadEvent;
    
    
        public class MyExample extends MovieClip {
            protected var _groupLoad:GroupLoad;
            protected var _imageOne:GraphicLoad;
            protected var _imageTwo:GraphicLoad;
            protected var _imageThree:GraphicLoad;
            protected var _imageFour:GraphicLoad;
    
    
            public function MyExample() {
                super();
    
                this._imageOne   = new GraphicLoad("test1.jpg");
                this._imageTwo   = new GraphicLoad("test2.jpg");
                this._imageThree = new GraphicLoad("test3.jpg");
                this._imageFour  = new GraphicLoad("test4.jpg");
    
                this._imageTwo.loader.x   = 10;
                this._imageThree.loader.x = 20;
                this._imageFour.loader.x  = 30;
    
                this.addChild(this._imageOne.loader);
                this.addChild(this._imageTwo.loader);
                this.addChild(this._imageThree.loader);
                this.addChild(this._imageFour.loader);
    
                this._groupLoad = new GroupLoad();
                this._groupLoad.addLoad(this._imageOne);
                this._groupLoad.addLoad(this._imageTwo);
                this._groupLoad.addLoad(this._imageThree);
                this._groupLoad.addLoad(this._imageFour);
                this._groupLoad.addEventListener(LoadEvent.PROGRESS, this._onProgress);
                this._groupLoad.addEventListener(LoadEvent.COMPLETE, this._onComplete);
                this._groupLoad.start();
            }
    
            protected function _onProgress(e:LoadEvent):void {
                trace("Group is " + e.progress.percentage + "% loaded at " + e.Bps + "Bps.");
            }
    
            protected function _onComplete(e:LoadEvent):void {
                trace("Group has loaded.");
            }
        }
    }
Events broadcasted to listeners:
  • LoadEvent with type: PROGRESS - Dispatched as the loads in the group are downloading.
  • LoadEvent with type: COMPLETE - When GroupLoad has completed loading all the loads in the group.

Summary


Constructor
Class properties
Class properties inherited from ProcessGroup
Class properties inherited from Process
Instance properties
  • loads : Array
    • The loads that compose the group.
  • preventCache : Boolean
    • Specifies if a random value name/value pair should be appended to every load in GroupLoad true, or not append false; defaults to false.
  • progress : Percent
    • The percent that the group is loaded.
  • loading : Boolean
    • Determines if the group is loading true, or if it isn't currently loading false.
  • loaded : Boolean
    • Determines if all loads in the group are loaded true, or if the group hasn't finished loading false.
  • Bps : int
    • The current download speed of the group in bytes per second.
Instance methods

Constructor

GroupLoad

public function GroupLoad (
)

Creates a new GroupLoad.

Instance properties

Bps

public Bps:int
(read)

The current download speed of the group in bytes per second.

loaded

public loaded:Boolean
(read)

Determines if all loads in the group are loaded true, or if the group hasn't finished loading false.

loading

public loading:Boolean
(read)

Determines if the group is loading true, or if it isn't currently loading false.

loads

public loads:Array
(read)

The loads that compose the group.
Returns:
  • Returns an Array containing all loads in the group.

preventCache

public preventCache:Boolean
(read,write)

Specifies if a random value name/value pair should be appended to every load in GroupLoad true, or not append false; defaults to false.

progress

public progress:Percent
(read)

The percent that the group is loaded.

Instance methods

addLoad

public function addLoad (
load:BaseLoadItem, percentOfGroup:Percent = null) : void

Add a load to the group.
Parameters:
load :
Load to be added to the group. Can be any class that extends from BaseLoadItem (Including another GroupLoad) and dispatches events LoadEvent.COMPLETE, LoadEvent.PROGRESS and IOErrorEvent.
percentOfGroup:
Defines the percentage of the total group the size of the load item represents; defaults to equal increments.

destroy

override public function destroy (
) : void

destroyLoads

public function destroyLoads (
) : void

Calls destroy on all loads in the group and removes them from the GroupLoad.

removeLoad

public function removeLoad (
load:BaseLoadItem) : void

Removes a load item from the group.
Parameters:
load:
Load to be removed from the group.