GroupLoad

Kind of class:public class
Package:org.casalib.load
Inherits from:ProcessGroup < Process < RemovableEventDispatcher < EventDispatcher
Version:09/06/09
Author:Aaron Clinger
Classpath:org.casalib.load.GroupLoad
File last modified:Sunday, 06 September 2009, 09:05:44
Allows multiple loads to be grouped and treated as one larger load.
Example:
  • package {
        import org.casalib.display.CasaMovieClip;
        import org.casalib.events.LoadEvent;
        import org.casalib.load.GroupLoad;
        import org.casalib.load.ImageLoad;
    
    
        public class MyExample extends CasaMovieClip {
            protected var _groupLoad:GroupLoad;
            protected var _imageOne:ImageLoad;
            protected var _imageTwo:ImageLoad;
            protected var _imageThree:ImageLoad;
            protected var _imageFour:ImageLoad;
    
    
            public function MyExample() {
                super();
    
                this._imageOne   = new ImageLoad("test1.jpg");
                this._imageTwo   = new ImageLoad("test2.jpg");
                this._imageThree = new ImageLoad("test3.jpg");
                this._imageFour  = new ImageLoad("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
Constants
Constants inherited from ProcessGroup
Class properties
Class properties inherited from ProcessGroup
Class properties inherited from Process
Instance properties
  • loads : Array
    • The loads that compose the group.
  • queuedLoads : Array
    • The loads that are neither complete nor loading.
  • loadingLoads : Array
    • The loads that are currently loading.
  • incompletedLoads : Array
    • The loads that have not completed.
  • completedLoads : Array
    • The loads that have completed.
  • 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.

completedLoads

public completedLoads:Array
(read)

The loads that have completed.

incompletedLoads

public incompletedLoads:Array
(read)

The loads that have not completed.

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.

loadingLoads

public loadingLoads:Array
(read)

The loads that are currently loading.

loads

public loads:Array
(read)

The loads that compose 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.

queuedLoads

public queuedLoads:Array
(read)

The loads that are neither complete nor loading.

Instance methods

addLoad

public function addLoad (
load:LoadItem, 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 LoadItem.
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.

hasLoad

public function hasLoad (
load:LoadItem) : Boolean

Determines if this GroupLoad contains a specific load item.
Parameters:
load:
The load item to search for.
Returns:
  • Returns true if the GroupLoad contains the load item; otherwise false.

removeLoad

public function removeLoad (
load:LoadItem) : void

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