Packagecom.pcthomatos.ultraloader
Classpublic class UltraLoader
InheritanceUltraLoader Inheritance flash.display.Sprite

The UltraLoader class is designed to dynamically preload all types of media assets into a storage object.

Once the class has been instatiated, load in assets using the load method. The load method requires the following parameters: See the load method for more details.


The <ul><li> construct:

The ULNode list follows the html <ul><li> construct. Every <ul>, <li> tag must have an id (id="foobar") associated with it. Each id value should be case sensitive and contain no spaces and should be globally unique across all other <ul><li> blocks and all subsequent load calls.
Most other attribute names are prefixed with "data-" to keep the html, X/HTML 5 compliant - in case it is placed on an html page.


Example
An example of the UltraLoader <ul><li> construct:
        <ul id="introcontent">
            <li data-type="htmlfield" id="sometext" data-width="400">
                <span class="foo">Welcome Folks<br />Welcome to UltraLoader</span>
                <br /><img src="img/testimage0.jpg" width="359" height="316" alt="" id="testimage"/> <br />
                <br /><img src="img/testimage0.jpg" width="359" height="316" alt="" id="testimage2"/> <br />
            </li>
        </ul>
        <ul id="musicphoto">
            <li data-type="image"><img src="img/testimage0.jpg" width="359" height="316" alt="" id="testimage3"/></li>
            <li data-type="string" id="sometext2">someText here for now</li>
            <li data-type="xml" id="somexml" data-src="xml/test.xml?teste=foo&bar=test"></li>
            <li data-type="policy" data-src="http://www.website.com/folder/policy.xml"></li>
            <li data-type="sound" id="testsound" data-src="snd/test.mp3"></li>
            <li data-type="sound" id="testsound2" data-src="snd/test2.mp3" data-policy="true"></li>
        </ul>
        <ul id="videos">
            <li data-type="video" id="testvid" data-src="vid/test.flv" data-width="320" data-height="240"></li>
            <li data-type="video" id="testvid2" data-src="http://video.ak.facebook.com/31552_33358.flv" data-width="320" data-height="240"></li>
        </ul>
        <ul id="animationswfs">
            <li data-type="policy" data-src="http://www.adifferent-website.com/subfolder/policy.xml"></li>
            <li data-type="flash" id="testswf" data-src="swf/AnimationTest2.swf"></li>
            <li data-type="flash" id="testswf2" data-src="swf/AnimationTest.swf?foo=bar"></li>
        </ul>
        

Types of assets:

The types of assets you can load with UltraLoader are:

To load and access each UltraLoader asset type:

*Note: UltraLoader has a validator built in.
If your <ul><li> construct contains missing or incorrect syntax, view the trace statements in your debugger to help identify where your XMLList syntax is incorrect.



Public Methods
 MethodDefined by
  
UltraLoader(ul:Object, onlyLoadBuffer:Boolean = false, dispObjP:DisplayObjectContainer = null, preloaderClassP:Class = null, loaderTextColorP:uint = 0xFFFFFF, loaderBytesColorP:uint = 0xFF6666, loaderBarColorP:uint = 0x66FF66, loaderBarBorderColorP:uint = 0x666666)
Defines the UltraLoader Object (parameter: ul) that will contain all the loaded assets and the loader screen's color settings.
UltraLoader
  
load(pageIdP:String, ulNodesP:XMLList, finalLoadP:Boolean = true):void
Loads in UL XML data into UltraLoader
UltraLoader
Public Constants
 ConstantDefined by
  LOAD_REQUEST_COMPLETE : String = "ultraLoaderComplete"
[static] The UltraLoader.LOAD_REQUEST_COMPLETE constant defines the value of the type property of the event object for a ultraLoaderComplete event.
Once this event is triggered you can set your ultraloader instance to null.
UltraLoader
Constructor detail
UltraLoader()constructor
public function UltraLoader(ul:Object, onlyLoadBuffer:Boolean = false, dispObjP:DisplayObjectContainer = null, preloaderClassP:Class = null, loaderTextColorP:uint = 0xFFFFFF, loaderBytesColorP:uint = 0xFF6666, loaderBarColorP:uint = 0x66FF66, loaderBarBorderColorP:uint = 0x666666)

Defines the UltraLoader Object (parameter: ul) that will contain all the loaded assets and the loader screen's color settings.

Parameters
ul:Object — ul A non null storage object.
For example:
public static var ul:Object = { init:true };

This Object will contain all of the assets loaded in with UltraLoader.

 
onlyLoadBuffer:Boolean (default = false) — onlyLoadBuffer Enables or disables the preloading of a sound's buffer (8 seconds) or the entire sound.

If set to true, UltraLoader loads faster. UltraLoader waits until enough sound is buffered and dispatches an UltraLoader.LOAD_REQUEST_COMPLETE Event, while the rest loads in the background.

If set to false, UltraLoader will not complete until sounds are fully loaded. Best used on unreliable servers.

 
dispObjP:DisplayObjectContainer (default = null) — An instance of DisplayObjectContainer (Sprite, MovieClip, Stage).

*Note: If DisplayObjectContainer is not passed the preloader will not display.

 
preloaderClassP:Class (default = null) — preloaderClassP Sets a preloader Custom Class so you can design your own. But it must implment ULPreloaderInterface. Other preloader parameters are ignored when a custom class is used.

 
loaderTextColorP:uint (default = 0xFFFFFF) — loaderTextColorP Sets the preloader text color for the preloader status text ("Initializing Loader", "Loading...").

 
loaderBytesColorP:uint (default = 0xFF6666) — loaderBytesColorP Sets the preloader text color for the bytes loaded / bytes total text.

 
loaderBarColorP:uint (default = 0x66FF66) — loaderBarColorP Sets the preloader loader bar color.

 
loaderBarBorderColorP:uint (default = 0x666666) — loaderBarBorderColorP Sets the preloader loader bar border color.

See also

Method detail
load()method
public function load(pageIdP:String, ulNodesP:XMLList, finalLoadP:Boolean = true):void

Loads in UL XML data into UltraLoader

Parameters
pageIdP:String — pageIdP A superNode identifier. This helps classify UL XML data from different source files.

 
ulNodesP:XMLList — ulNodesP A UL XML List containing asset information.

 
finalLoadP:Boolean (default = true) — finalLoadP A flag to determine when actual loading should commence.

If set to true, the default, UltraLoader will commence loading.
If set to false, UltraLoader will only append data to the queue.

*Note: Loading will not commence until a load call has the finalLoadP parameter set to true.

Example
Usage with one UltraLoader load call:
            ...
            var ultraLoader:UltraLoader = new UltraLoader(ulObj);
            ultraLoader.addEventListener(UltraLoader.LOAD_REQUEST_COMPLETE, killLoader_Listener);
            ultraLoader.load("index", ulXMLData);
        }

        private function killLoader_Listener(e:Event):void {
            e.currentTarget.removeEventListener(UltraLoader.LOAD_REQUEST_COMPLETE, killLoader_Listener);
            ...

Usage with multiple UltraLoader load calls:
            ...
            var ultraLoader:UltraLoader = new UltraLoader(ulObj);
            ultraLoader.addEventListener(UltraLoader.LOAD_REQUEST_COMPLETE, killLoader_Listener);
            ultraLoader.load("page1", ulXMLData1, false);
            ultraLoader.load("page2", ulXMLData2, false);
            ultraLoader.load("page3", ulXMLData3); // or explicitly ultraLoader.load("page3", ulXMLData3, true);
        }
        private function killLoader_Listener(e:Event):void {
            e.currentTarget.removeEventListener(UltraLoader.LOAD_REQUEST_COMPLETE, killLoader_Listener);
            ...

Constant detail
LOAD_REQUEST_COMPLETEconstant
public static const LOAD_REQUEST_COMPLETE:String = "ultraLoaderComplete"

The UltraLoader.LOAD_REQUEST_COMPLETE constant defines the value of the type property of the event object for a ultraLoaderComplete event.
Once this event is triggered you can set your ultraloader instance to null.


Example
The following code sets the volume level for your sound:
            ...
            var ultraLoader:UltraLoader = new UltraLoader(ulObj);
            ultraLoader.addEventListener(UltraLoader.LOAD_REQUEST_COMPLETE, killLoader_Listener);
        }

        private function killLoader_Listener(e:Event):void {
            e.currentTarget.removeEventListener(UltraLoader.LOAD_REQUEST_COMPLETE, killLoader_Listener);
            ...