API Documentation | All Packages | All Classes | Index | Frames No Frames |
Class LoaderMaxVars

Package | com.greensock.loading.data
Class | public class LoaderMaxVars

Can be used instead of a generic Object to define the `vars` parameter of a LoaderMax's constructor.
There are 2 primary benefits of using a LoaderMaxVars instance to define your LoaderMax variables:

1. In most code editors, code hinting will be activated which helps remind you which special properties are available in LoaderMax
2. It enables strict data typing for improved debugging (ensuring, for example, that you don't define a Boolean value for `onComplete` where a Function is expected).

The down side, of course, is that the code is more verbose and the LoaderMaxVars class adds slightly more kb to your swf. USAGE:
Note that each method returns the LoaderMaxVars instance, so you can reduce the lines of code by method chaining (see example below).
Without LoaderMaxVars:
`new LoaderMax({name:"queue", maxConnections:1, onComplete:completeHandler, onProgress:progressHandler});`
With LoaderMaxVars
`new LoaderMax(new LoaderMaxVars().name("queue").maxConnections(1).onComplete(completeHandler).onProgress(progressHandler));`
NOTES:

- To get the generic vars object that LoaderMaxVars builds internally, simply access its "vars" property. In fact, if you want maximum backwards compatibility, you can tack ".vars" onto the end of your chain like this:
  `new LoaderMax(new LoaderMaxVars().name("queue").maxConnections(1).vars);`
- Using LoaderMaxVars is completely optional. If you prefer the shorter synatax with the generic Object, feel free to use it. The purpose of this class is simply to enable code hinting and to allow for strict data typing.

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.

Public Properties

| Property | Defined by
--- | --- | ---
|  | vars : Object [read-only] The generic Object populated by all of the method calls in the LoaderMaxVars instance. | LoaderMaxVars

Public Methods

| Method | Defined by
--- | --- | ---
|  | LoaderMaxVars(vars:Object = null) Constructor | LoaderMaxVars
|  | auditSize(value:Boolean):LoaderMaxVars By default, when the LoaderMax begins to load it quickly loops through its children and if it finds any that don't have an `estimatedBytes` defined, it will briefly open a URLStream in order to attempt to determine its `bytesTotal`, immediately closing the URLStream once the value has been determined. | LoaderMaxVars
|  | autoDispose(value:Boolean):LoaderMaxVars When `autoDispose` is `true`, the loader will be disposed immediately after it completes (it calls the `dispose()` method internally after dispatching its `COMPLETE` event). | LoaderMaxVars
|  | autoLoad(value:Boolean):LoaderMaxVars If `true`, the LoaderMax instance will automatically call `load()` whenever you insert()/append()/prepend() a new loader whose status is `LoaderStatus.READY`. | LoaderMaxVars
|  | loaders(value:Array):LoaderMaxVars An array of loaders (ImageLoaders, SWFLoaders, XMLLoaders, MP3Loaders, other LoaderMax instances, etc.) that should be immediately inserted into the LoaderMax. | LoaderMaxVars
|  | maxConnections(value:uint):LoaderMaxVars Maximum number of simultaneous connections that should be used while loading the LoaderMax queue. | LoaderMaxVars
|  | name(value:String):LoaderMaxVars A name that is used to identify the loader instance. | LoaderMaxVars
|  | onCancel(value:Function):LoaderMaxVars A handler function for `LoaderEvent.CANCEL` events which are dispatched when loading is aborted due to either a failure or because another loader was prioritized or `cancel()` was manually called. | LoaderMaxVars
|  | onChildCancel(value:Function):LoaderMaxVars A handler function for `LoaderEvent.CHILD_CANCEL` events which are dispatched each time loading is aborted on one of the loader's children (or any descendant) due to either an error or because another loader was prioritized in the queue or because `cancel()` was manually called on the child loader. | LoaderMaxVars
|  | onChildComplete(value:Function):LoaderMaxVars A handler function for `LoaderEvent.CHILD_COMPLETE` events which are dispatched each time one of the loader's children (or any descendant) finishes loading successfully. | LoaderMaxVars
|  | onChildFail(value:Function):LoaderMaxVars A handler function for `LoaderEvent.CHILD_FAIL` events which are dispatched each time one of the loader's children (or any descendant) fails (and its `status` chances to `LoaderStatus.FAILED`). | LoaderMaxVars
|  | onChildOpen(value:Function):LoaderMaxVars A handler function for `LoaderEvent.CHILD_OPEN` events which are dispatched each time one of the loader's children (or any descendant) begins loading. | LoaderMaxVars
|  | onChildProgress(value:Function):LoaderMaxVars A handler function for `LoaderEvent.CHILD_PROGRESS` events which are dispatched each time one of the loader's children (or any descendant) dispatches a `PROGRESS` event. | LoaderMaxVars
|  | onComplete(value:Function):LoaderMaxVars A handler function for `LoaderEvent.COMPLETE` events which are dispatched when the loader has finished loading successfully. | LoaderMaxVars
|  | onError(value:Function):LoaderMaxVars A handler function for `LoaderEvent.ERROR` events which are dispatched whenever the loader experiences an error (typically an IO_ERROR or SECURITY_ERROR). | LoaderMaxVars
|  | onFail(value:Function):LoaderMaxVars A handler function for `LoaderEvent.FAIL` events which are dispatched whenever the loader fails and its `status` changes to `LoaderStatus.FAILED`. | LoaderMaxVars
|  | onHTTPStatus(value:Function):LoaderMaxVars A handler function for `LoaderEvent.HTTP_STATUS` events. | LoaderMaxVars
|  | onIOError(value:Function):LoaderMaxVars A handler function for `LoaderEvent.IO_ERROR` events which will also call the onError handler, so you can use that as more of a catch-all whereas `onIOError` is specifically for LoaderEvent.IO_ERROR events. | LoaderMaxVars
|  | onOpen(value:Function):LoaderMaxVars A handler function for `LoaderEvent.OPEN` events which are dispatched when the loader begins loading. | LoaderMaxVars
|  | onProgress(value:Function):LoaderMaxVars A handler function for `LoaderEvent.PROGRESS` events which are dispatched whenever the `bytesLoaded` changes. | LoaderMaxVars
|  | onScriptAccessDenied(value:Function):LoaderMaxVars A handler function for `LoaderEvent.SCRIPT_ACCESS_DENIED` events which are dispatched when one of the LoaderMax's children (or any descendant) is loaded from another domain and no crossdomain.xml is in place to grant full script access for things like smoothing or BitmapData manipulation. | LoaderMaxVars
|  | prop(property:String, value:*):LoaderMaxVars Adds a dynamic property to the vars object containing any value you want. | LoaderMaxVars
|  | requireWithRoot(value:DisplayObject):LoaderMaxVars LoaderMax supports subloading, where an object can be factored into a parent's loading progress. | LoaderMaxVars
|  | skipFailed(value:Boolean):LoaderMaxVars If `skipFailed` is `true` (the default), any failed loaders in the queue will be skipped. | LoaderMaxVars
|  | skipPaused(value:Boolean):LoaderMaxVars If `skipPaused` is `true` (the default), any paused loaders in the queue will be skipped. | LoaderMaxVars

Property detail

vars | property

`vars:Object` [read-only]

The generic Object populated by all of the method calls in the LoaderMaxVars instance. This is the raw data that gets passed to the loader.

Implementation
`public function get vars():Object`
Constructor detail

LoaderMaxVars | () | constructor

`public function LoaderMaxVars(vars:Object = null)`

Constructor

Parameters

| `vars:Object` (default = `null`)`` — A generic Object containing properties that you'd like to add to this LoaderMaxVars instance.

Method detail

auditSize | () | method

`public function auditSize(value:Boolean):LoaderMaxVars`

By default, when the LoaderMax begins to load it quickly loops through its children and if it finds any that don't have an `estimatedBytes` defined, it will briefly open a URLStream in order to attempt to determine its `bytesTotal`, immediately closing the URLStream once the value has been determined. This causes a brief delay initially, but greatly improves the accuracy of the `progress` and `bytesTotal` values. Set `auditSize` to `false` to prevent the LoaderMax from auditing its childrens' size (it is `true` by default). For maximum performance, it is best to define an `estimatedBytes` value for as many loaders as possible to avoid the delay caused by audits. When the LoaderMax audits an XMLLoader, it cannot recognize loaders that will be created from the XML data nor can it recognize loaders inside subloaded swf files from a SWFLoader (it would take far too long to load sufficient data for that - audits should be as fast as possible). If you do not set an appropriate `estimatedSize` for XMLLoaders or SWFLoaders that contain LoaderMax loaders, you'll notice that the parent LoaderMax's `progress` and `bytesTotal` change when the nested loaders are recognized (this is normal). To control the default `auditSize` value, use the static `LoaderMax.defaultAuditSize` property.

Parameters

| `value:Boolean`

Returns

| `LoaderMaxVars`

autoDispose | () | method |

`public function autoDispose(value:Boolean):LoaderMaxVars`

When `autoDispose` is `true`, the loader will be disposed immediately after it completes (it calls the `dispose()` method internally after dispatching its `COMPLETE` event). This will remove any listeners that were defined in the vars object (like onComplete, onProgress, onError, onInit). Once a loader is disposed, it can no longer be found with `LoaderMax.getLoader()` or `LoaderMax.getContent()` - it is essentially destroyed but its content is not unloaded (you must call `unload()` or `dispose(true)` to unload its content). The default `autoDispose` value is `false`.

Parameters

| `value:Boolean`

Returns

| `LoaderMaxVars`

autoLoad | () | method |

`public function autoLoad(value:Boolean):LoaderMaxVars`

If `true`, the LoaderMax instance will automatically call `load()` whenever you insert()/append()/prepend() a new loader whose status is `LoaderStatus.READY`. This basically makes it easy to create a LoaderMax queue and dump stuff into it whenever you want something to load without having to check the LoaderMax's status and call `load()` manually if it's not already loading.

Parameters

| `value:Boolean`

Returns

| `LoaderMaxVars`

loaders | () | method |

`public function loaders(value:Array):LoaderMaxVars`

An array of loaders (ImageLoaders, SWFLoaders, XMLLoaders, MP3Loaders, other LoaderMax instances, etc.) that should be immediately inserted into the LoaderMax.

Parameters

| `value:Array`

Returns

| `LoaderMaxVars`

maxConnections | () | method |

`public function maxConnections(value:uint):LoaderMaxVars`

Maximum number of simultaneous connections that should be used while loading the LoaderMax queue. A higher number will generally result in faster overall load times for the group. The default is 2. This value is instance-based, not system-wide, so if you have two LoaderMax instances that both have a `maxConnections` value of 3 and they are both loading, there could be up to 6 connections at a time total. Sometimes there are limits imposed by the Flash Player itself or the browser or the user's system, but LoaderMax will do its best to honor the `maxConnections` you define.

Parameters

| `value:uint`

Returns

| `LoaderMaxVars`

name | () | method |

`public function name(value:String):LoaderMaxVars`

A name that is used to identify the loader instance. This name can be fed to the `LoaderMax.getLoader()` or `LoaderMax.getContent()` methods or traced at any time. Each loader's name should be unique. If you don't define one, a unique name will be created automatically, like "loader21".

Parameters

| `value:String`

Returns

| `LoaderMaxVars`

onCancel | () | method |

`public function onCancel(value:Function):LoaderMaxVars`

A handler function for `LoaderEvent.CANCEL` events which are dispatched when loading is aborted due to either a failure or because another loader was prioritized or `cancel()` was manually called. Make sure your onCancel function accepts a single parameter of type `LoaderEvent` (`com.greensock.events.LoaderEvent`).

Parameters

| `value:Function`

Returns

| `LoaderMaxVars`

onChildCancel | () | method |

`public function onChildCancel(value:Function):LoaderMaxVars`

A handler function for `LoaderEvent.CHILD_CANCEL` events which are dispatched each time loading is aborted on one of the loader's children (or any descendant) due to either an error or because another loader was prioritized in the queue or because `cancel()` was manually called on the child loader. Make sure your onChildCancel function accepts a single parameter of type `LoaderEvent` (`com.greensock.events.LoaderEvent`).

Parameters

| `value:Function`

Returns

| `LoaderMaxVars`

onChildComplete | () | method |

`public function onChildComplete(value:Function):LoaderMaxVars`

A handler function for `LoaderEvent.CHILD_COMPLETE` events which are dispatched each time one of the loader's children (or any descendant) finishes loading successfully. Make sure your onChildComplete function accepts a single parameter of type `LoaderEvent` (`com.greensock.events.LoaderEvent`).

Parameters

| `value:Function`

Returns

| `LoaderMaxVars`

onChildFail | () | method |

`public function onChildFail(value:Function):LoaderMaxVars`

A handler function for `LoaderEvent.CHILD_FAIL` events which are dispatched each time one of the loader's children (or any descendant) fails (and its `status` chances to `LoaderStatus.FAILED`). Make sure your onChildFail function accepts a single parameter of type `LoaderEvent` (`com.greensock.events.LoaderEvent`).

Parameters

| `value:Function`

Returns

| `LoaderMaxVars`

onChildOpen | () | method |

`public function onChildOpen(value:Function):LoaderMaxVars`

A handler function for `LoaderEvent.CHILD_OPEN` events which are dispatched each time one of the loader's children (or any descendant) begins loading. Make sure your onChildOpen function accepts a single parameter of type `LoaderEvent` (`com.greensock.events.LoaderEvent`).

Parameters

| `value:Function`

Returns

| `LoaderMaxVars`

onChildProgress | () | method |

`public function onChildProgress(value:Function):LoaderMaxVars`

A handler function for `LoaderEvent.CHILD_PROGRESS` events which are dispatched each time one of the loader's children (or any descendant) dispatches a `PROGRESS` event. To listen for changes in the LoaderMax's overall progress, use the `onProgress` special property instead. You can use the LoaderEvent's `target.progress` to get the child loader's progress value or use its `target.bytesLoaded` and `target.bytesTotal`. The LoaderEvent's `currentTarget` refers to the LoaderMax, so you can check its overall progress with the LoaderEvent's `currentTarget.progress`. Make sure your onChildProgress function accepts a single parameter of type `LoaderEvent` (`com.greensock.events.LoaderEvent`).

Parameters

| `value:Function`

Returns

| `LoaderMaxVars`

onComplete | () | method |

`public function onComplete(value:Function):LoaderMaxVars`

A handler function for `LoaderEvent.COMPLETE` events which are dispatched when the loader has finished loading successfully. Make sure your onComplete function accepts a single parameter of type `LoaderEvent` (`com.greensock.events.LoaderEvent`).

Parameters

| `value:Function`

Returns

| `LoaderMaxVars`

onError | () | method |

`public function onError(value:Function):LoaderMaxVars`

A handler function for `LoaderEvent.ERROR` events which are dispatched whenever the loader experiences an error (typically an IO_ERROR or SECURITY_ERROR). An error doesn't necessarily mean the loader failed, however - to listen for when a loader fails, use the `onFail` special property. Make sure your onError function accepts a single parameter of type `LoaderEvent` (`com.greensock.events.LoaderEvent`).

Parameters

| `value:Function`

Returns

| `LoaderMaxVars`

onFail | () | method |

`public function onFail(value:Function):LoaderMaxVars`

A handler function for `LoaderEvent.FAIL` events which are dispatched whenever the loader fails and its `status` changes to `LoaderStatus.FAILED`. Make sure your onFail function accepts a single parameter of type `LoaderEvent` (`com.greensock.events.LoaderEvent`).

Parameters

| `value:Function`

Returns

| `LoaderMaxVars`

onHTTPStatus | () | method |

`public function onHTTPStatus(value:Function):LoaderMaxVars`

A handler function for `LoaderEvent.HTTP_STATUS` events. Make sure your onHTTPStatus function accepts a single parameter of type `LoaderEvent` (`com.greensock.events.LoaderEvent`). You can determine the httpStatus code using the LoaderEvent's `target.httpStatus` (LoaderItems keep track of their `httpStatus` when possible, although certain environments prevent Flash from getting httpStatus information).

Parameters

| `value:Function`

Returns

| `LoaderMaxVars`

onIOError | () | method |

`public function onIOError(value:Function):LoaderMaxVars`

A handler function for `LoaderEvent.IO_ERROR` events which will also call the onError handler, so you can use that as more of a catch-all whereas `onIOError` is specifically for LoaderEvent.IO_ERROR events. Make sure your onIOError function accepts a single parameter of type `LoaderEvent` (`com.greensock.events.LoaderEvent`).

Parameters

| `value:Function`

Returns

| `LoaderMaxVars`

onOpen | () | method |

`public function onOpen(value:Function):LoaderMaxVars`

A handler function for `LoaderEvent.OPEN` events which are dispatched when the loader begins loading. Make sure your onOpen function accepts a single parameter of type `LoaderEvent` (`com.greensock.events.LoaderEvent`).

Parameters

| `value:Function`

Returns

| `LoaderMaxVars`

onProgress | () | method |

`public function onProgress(value:Function):LoaderMaxVars`

A handler function for `LoaderEvent.PROGRESS` events which are dispatched whenever the `bytesLoaded` changes. Make sure your onProgress function accepts a single parameter of type `LoaderEvent` (`com.greensock.events.LoaderEvent`). You can use the LoaderEvent's `target.progress` to get the loader's progress value or use its `target.bytesLoaded` and `target.bytesTotal`.

Parameters

| `value:Function`

Returns

| `LoaderMaxVars`

onScriptAccessDenied | () | method |

`public function onScriptAccessDenied(value:Function):LoaderMaxVars`

A handler function for `LoaderEvent.SCRIPT_ACCESS_DENIED` events which are dispatched when one of the LoaderMax's children (or any descendant) is loaded from another domain and no crossdomain.xml is in place to grant full script access for things like smoothing or BitmapData manipulation. Make sure your function accepts a single parameter of type `LoaderEvent` (`com.greensock.events.LoaderEvent`).

Parameters

| `value:Function`

Returns

| `LoaderMaxVars`

prop | () | method |

`public function prop(property:String, value:*):LoaderMaxVars`

Adds a dynamic property to the vars object containing any value you want. This can be useful in situations where you need to associate certain data with a particular loader. Just make sure that the property name is a valid variable name (starts with a letter or underscore, no special characters, etc.) and that it doesn't use a reserved property name like "name" or "onComplete", etc. For example, to set an "index" property to 5, do: `prop("index", 5);`

Parameters

| `property:String` — Property name
| `value:*` — Value

Returns

| `LoaderMaxVars`

requireWithRoot | () | method |

`public function requireWithRoot(value:DisplayObject):LoaderMaxVars`

LoaderMax supports subloading, where an object can be factored into a parent's loading progress. If you want LoaderMax to require this loader as part of its parent SWFLoader's progress, you must set the `requireWithRoot` property to your swf's `root`. For example, `vars.requireWithRoot = this.root;`.

Parameters

| `value:DisplayObject`

Returns

| `LoaderMaxVars`

skipFailed | () | method |

`public function skipFailed(value:Boolean):LoaderMaxVars`

If `skipFailed` is `true` (the default), any failed loaders in the queue will be skipped. Otherwise, the LoaderMax will stop when it hits a failed loader and the LoaderMax's status will become `LoaderStatus.FAILED`.

Parameters

| `value:Boolean`

Returns

| `LoaderMaxVars`

skipPaused | () | method |

`public function skipPaused(value:Boolean):LoaderMaxVars`

If `skipPaused` is `true` (the default), any paused loaders in the queue will be skipped. Otherwise, the LoaderMax will stop when it hits a paused loader and the LoaderMax's status will become `LoaderStatus.FAILED`.

Parameters

| `value:Boolean`

Returns

| `LoaderMaxVars`