| Package | net.guttershark.control |
| Class | public final class PreloadController |
| Inheritance | PreloadController flash.events.EventDispatcher |
import net.guttershark.control.PreloadController;
import net.guttershark.managers.AssetManager;
import net.guttershark.managers.EventManager;
import net.guttershark.support.preloading.Asset;
public class PreloaderTest extends DocumentController
{
public var preloader:MovieClip;
public function PreloaderTest()
{
super();
}
private function setupComplete():void
{
pc = new PreloadController(400);
var assets:Array = [
new Asset("assets/jpg1.jpg","jpg1"),
new Asset("assets/jpg2.jpg","jpg2"),
new Asset("assets/png1.png","png1"),
new Asset("assets/png2.png","png2"),
new Asset("swfload_test.swf","swf1"),
new Asset("assets/sound1.mp3","snd1"),
new Asset("assets/Pizza_Song.flv","pizza")
];
pc.addItems(assets);
em.handleEvents(pc,this,"onPC",true);
pc.prioritize(assets[4]); //prioritize the swf.
pc.start(); //start it;
pc.stop(); //pause it
setTimeout(pc.start,4000); //resume it
}
private function onPCProgress(pe:PreloadProgressEvent):void
{
trace(pe.toString());
preloader.width = pe.pixels
}
private function onPCAssetComplete(e:AssetCompleteEvent):void
{
trace(e.toString());
}
private function onPCComplete(e:Event):void
{
addChild(am.getMovieClipFromSWFLibrary("swf1", "Test"));
addChild(am.getBitmap("jpg1"));
}
}
| Property | Defined by | ||
|---|---|---|---|
| lastCompletedAsset : Asset
[read-only]
The last completed asset.
| PreloadController | ||
| numLeft : int [read-only]
The number of items left in the preload queue.
| PreloadController | ||
| pixelsToFill : int [write-only]
Set the number of pixels to fill, useful if
the pixel calculations need to change.
| PreloadController | ||
| working : Boolean [read-only]
Indicates whether or not this controller is doing any preloading.
| PreloadController | ||
| Method | Defined by | ||
|---|---|---|---|
|
PreloadController(pixelsToFill:int = 100)
Constructor for PreloadController instances.
| PreloadController | ||
|
addItems(items:Array):void
Add items to the controller to load - if the preloader is currently working,
these items will be appended to the items to load.
| PreloadController | ||
|
addPrioritizedItems(items:Array):void
Add items to the controller to load, with top priority.
| PreloadController | ||
|
dispose():void
Dispose of this preloadController.
| PreloadController | ||
|
prioritize(asset:Asset):void
Prioritize an asset.
| PreloadController | ||
|
reset():void
Resets internal state.
| PreloadController | ||
|
start():void
Starts loading the assets, and resumes loading from a stopped state.
| PreloadController | ||
|
stop():void
Stops this preload controller from loading assets, if there is
an asset currently loading, that asset will finish loading, but the
controller will not continue after that.
| PreloadController | ||
| Event | Summary | Defined by | ||
|---|---|---|---|---|
| Dispatched for each asset that has completed downloading. | PreloadController | |||
| Dispatched for each asset that has has stopped downloading because of an error. | PreloadController | |||
| Dispatched for each asset that has started downloading. | PreloadController | |||
| Dispatched for each asset that is downloading. | PreloadController | |||
| Dispatched for each asset that generated an http status code other than 0 or 200. | PreloadController | |||
| Dispatched when the preload controller completes downloading all assets in the queue. | PreloadController | |||
| Dispatched on progress of the entire PreloadController progress. | PreloadController | |||
| lastCompletedAsset | property |
lastCompletedAsset:Asset [read-only]The last completed asset.
Implementation public function get lastCompletedAsset():Asset
| numLeft | property |
numLeft:int [read-only]The number of items left in the preload queue.
Implementation public function get numLeft():int
| pixelsToFill | property |
pixelsToFill:int [write-only]Set the number of pixels to fill, useful if the pixel calculations need to change.
Implementation public function set pixelsToFill(value:int):void
| working | property |
working:Boolean [read-only]Indicates whether or not this controller is doing any preloading.
Implementation public function get working():Boolean
| PreloadController | () | constructor |
public function PreloadController(pixelsToFill:int = 100)Constructor for PreloadController instances.
ParameterspixelsToFill:int (default = 100) — pixelsToFill The total number of pixels this preloader needs to fill - this is used in calculating both pixels and percent.
|
See also
| addItems | () | method |
public function addItems(items:Array):voidAdd items to the controller to load - if the preloader is currently working, these items will be appended to the items to load.
Parametersitems:Array — An array of Asset instances.
|
See also
| addPrioritizedItems | () | method |
public function addPrioritizedItems(items:Array):voidAdd items to the controller to load, with top priority.
Parametersitems:Array — An array of Asset instances.
|
See also
| dispose | () | method |
public function dispose():voidDispose of this preloadController.
| prioritize | () | method |
public function prioritize(asset:Asset):voidPrioritize an asset.
Parametersasset:Asset — An asset instance that is in the queue to be loaded.
|
| reset | () | method |
public function reset():voidResets internal state.
| start | () | method |
public function start():voidStarts loading the assets, and resumes loading from a stopped state.
See also
| stop | () | method |
public function stop():voidStops this preload controller from loading assets, if there is an asset currently loading, that asset will finish loading, but the controller will not continue after that.
See also
| assetComplete | event |
net.guttershark.support.preloading.events.AssetCompleteEvent
Dispatched for each asset that has completed downloading.
| assetError | event |
net.guttershark.support.preloading.events.AssetErrorEvent
Dispatched for each asset that has has stopped downloading because of an error.
| assetOpen | event |
net.guttershark.support.preloading.events.AssetOpenEvent
Dispatched for each asset that has started downloading.
| assetProgress | event |
net.guttershark.support.preloading.events.AssetProgressEvent
Dispatched for each asset that is downloading.
| assetStatus | event |
net.guttershark.support.preloading.events.AssetStatusEvent
Dispatched for each asset that generated an http status code other than 0 or 200.
| complete | event |
flash.events.Event
Dispatched when the preload controller completes downloading all assets in the queue.
| preloadProgress | event |
net.guttershark.support.preloading.events.PreloadProgressEvent
Dispatched on progress of the entire PreloadController progress.