ActionScript® 3.0 Reference for the Adobe® Flash® Platform
Home  |  Show Packages and Classes List |  Packages  |  Classes  |  What's New  |  Index  |  Appendixes
fl.rsl 

RSLPreloader  - AS3 Flash

Packagefl.rsl
Classpublic class RSLPreloader
InheritanceRSLPreloader Inheritance EventDispatcher Inheritance Object

Language Version: ActionScript 3.0
Product Version: Flash CS5
Runtime Versions: Flash Player 10.1, AIR 2

The RSLPreloader class manages preloading of RSLs (Runtime Shared Libraries) before playing other content. It handles both SWF (unsigned) and SWZ (signed and cached) files. RSLPreloader dispatches events (RSLEvent.RSL_LOAD_COMPLETE, RSLErrorEvent.RSL_LOAD_FAILED or RSLEvent.RSL_PROGRESS) to indicate the status of RSL file loading.

Related API Elements



Public Properties
 PropertyDefined By
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  debugWaitTime : int
Set this value to the number of milliseconds to wait before downloading the first RSL file.
RSLPreloader
  numRSLInfos : int
[read-only] The number of RSLInfo instances added via addRSLInfo().
RSLPreloader
Public Methods
 MethodDefined By
  
RSLPreloader(mainTimeline:MovieClip = null)
Constructor.
RSLPreloader
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
EventDispatcher
  
Adds a descriptive RSLInfo record to the SWF or SWZ file being downloaded.
RSLPreloader
 Inherited
Dispatches an event into the event flow.
EventDispatcher
  
Gets the RSLInfo record added via addRSLInfo() at the specified index.
RSLPreloader
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
  
The loadContent method is called from frame 2 of the wrapper SWF when a content class name is supplied to the start() method.
RSLPreloader
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
  
start(preloaderAnimClass:Class = null, contentClassName:String = null):void
Starts downloading the RSL files.
RSLPreloader
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
Events
 Event Summary Defined By
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active.EventDispatcher
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive.EventDispatcher
  Dispatched by RSLPreloader when all RSLs have completed loading.RSLPreloader
  Dispatched by RSLPreloader when all RSLs have finished downloading and one or more have failed.RSLPreloader
  Dispatched by RSLPreloader to indicate progress in downloading RSL files.RSLPreloader
Property Detail

debugWaitTime

property
debugWaitTime:int

Language Version: ActionScript 3.0
Product Version: Flash CS5
Runtime Versions: Flash Player 10.1, AIR 2

Set this value to the number of milliseconds to wait before downloading the first RSL file. This is one way to simulate the end-user experience and test the preload loop. It is especially useful in testing signed cache RSLs (SWZ files), to build in a loading delay without flushing the SWZ cache. Disable any code that sets this value to greater than 0 before deploying. Use a debug config constant (such as CONFIG::DEBUG) to call the code. Another suggestion is to set the delay to a relatively LARGE value, such as 5000 (equivalent to 5 seconds), as a reminder to remove the debug code. For RSLLoader instances that are automatically generated by authoring, the dalay can be set by defining a setRSLPreloader(value:RSLPreloader):void method in the loading animation SWF or in the main timeline code.

         import fl.rsl.RSLPreloader;
         function setRSLPreloader(preloader:RSLPreloader):void {
         preloader.debugWaitTime = 10000;
         }
         

The default value is 0.



Implementation
    public function get debugWaitTime():int
    public function set debugWaitTime(value:int):void

numRSLInfos

property 
numRSLInfos:int  [read-only]

Language Version: ActionScript 3.0
Product Version: Flash CS5
Runtime Versions: Flash Player 10.1, AIR 2

The number of RSLInfo instances added via addRSLInfo().

         for(var i:int = 0; i < myPreloader.numRSLInfos; i++) {
            trace('rsl ' + i);
            var urls:Array = myPreloader.getRSLInfoAt(i).rslURLs;
            for(var j:int = 0; j < urls.length; j++) {
               trace(' url: ' + urls[j]);
            }
         }
         


Implementation
    public function get numRSLInfos():int

Related API Elements

Constructor Detail

RSLPreloader

()Constructor
public function RSLPreloader(mainTimeline:MovieClip = null)

Language Version: ActionScript 3.0
Product Version: Flash CS5
Runtime Versions: Flash Player 10.1, AIR 2

Constructor. When authoring outputs code automatically to preload SWZ files, it passes in the main timeline class as an argument. This is not generally useful for end-user written code.

Parameters
mainTimeline:MovieClip (default = null)
Method Detail

addRSLInfo

()method
public function addRSLInfo(info:RSLInfo):void

Language Version: ActionScript 3.0
Product Version: Flash CS5
Runtime Versions: Flash Player 10.1, AIR 2

Adds a descriptive RSLInfo record to the SWF or SWZ file being downloaded.

         import fl.rsl.RSLInfo;
         var info:RSLInfo = new RSLInfo();
         info.addEntry('rsl.swf');
         myPreloader.addRSLInfo(info);
         myPreloader.start();
         

Parameters

info:RSLInfo

getRSLInfoAt

()method 
public function getRSLInfoAt(index:int):RSLInfo

Language Version: ActionScript 3.0
Product Version: Flash CS5
Runtime Versions: Flash Player 10.1, AIR 2

Gets the RSLInfo record added via addRSLInfo() at the specified index. The index corresponds to the order in which the records were added via addRSLInfo().

         for (var i:int = 0; i < myPreloader.numRSLInfos; i++) {
            trace('rsl ' + i);
            var urls:Array = myPreloader.getRSLInfoAt(i).rslURLs;
            for (var j:int = 0; j < urls.length; j++) {
               trace(' url: ' + urls[j]);
            }
         }
         

Parameters

index:int

Returns
RSLInfo

Related API Elements

loadContent

()method 
public function loadContent():void

Language Version: ActionScript 3.0
Product Version: Flash CS5
Runtime Versions: Flash Player 10.1, AIR 2

The loadContent method is called from frame 2 of the wrapper SWF when a content class name is supplied to the start() method. It is not generally used with end-user written code.

Related API Elements

start

()method 
public function start(preloaderAnimClass:Class = null, contentClassName:String = null):void

Language Version: ActionScript 3.0
Product Version: Flash CS5
Runtime Versions: Flash Player 10.1, AIR 2

Starts downloading the RSL files. This function should not be called until all RSLInfo records have been added via addRSLInfo(). Two optional arguments may be used when authoring outputs code automatically. The first is a ByteArray subclass to load a preloader SWF animation. The second is the name of a ByteArray subclass for the content SWF, These arguments are not generally used in end-user written code.

Parameters

preloaderAnimClass:Class (default = null)
 
contentClassName:String (default = null)

Related API Elements

Event Detail

rslLoadComplete

Event
Event Object Type: fl.events.RSLEvent
property RSLEvent.type = fl.events.RSLEvent.RSL_LOAD_COMPLETE

Language Version: ActionScript 3.0
Product Version: Flash CS5
Runtime Versions: Flash Player 10.1, AIR 2

Dispatched by RSLPreloader when all RSLs have completed loading.

Event dispatched by RSLPreloader when all RSLs have successfully downloading. The bytesLoaded and bytesTotal properties are always 0 for this event type. When preloading with a custom event loop, user content MUST listen for this event to determine when to exit the loading animation loop.

This event has the following properties:

PropertyValue
bubblestrue
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe DisplayObject instance being added to the display list. The target is not always the object in the display list that registered the event listener. Use the currentTarget property to access the object in the display list that is currently processing the event.
rslsLoadedThe number of files that have downloaded successfully.
rslsFailedthe number of files that have failed to download.
rslsTotalthe total number of files that have downloaded, successfully or not.
bytesLoadedThe total number of downloaded bytes in files that have successfully downloaded.
bytesTotalthe total number of downloaded bytes in files that have downloaded, successful or not.
         import fl.events.RSLEvent;
         myPreloader.addEventListener(RSLEvent.RSL_LOAD_COMPLETE, loadComplete);
         function loadComplete(e:RSLEvent) {
         gotoAndPlay('startOfContent');
         }
         

rslLoadFailed

Event  
Event Object Type: fl.events.RSLErrorEvent
property RSLErrorEvent.type = fl.events.RSLErrorEvent.RSL_LOAD_FAILED

Language Version: ActionScript 3.0
Product Version: Flash CS5
Runtime Versions: Flash Player 10.1, AIR 2

Dispatched by RSLPreloader when all RSLs have finished downloading and one or more have failed.

Error dispatched by RSLPreloader when all RSLs have finished downloading and one or more have failed. When preloading with a custom event loop, user content MUST listen for this event to determine when to exit the loading animation loop.

This event has the following properties:

PropertyValue
bubblestrue
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe DisplayObject instance being added to the display list. The target is not always the object in the display list that registered the event listener. Use the currentTarget property to access the object in the display list that is currently processing the event.
rslsLoadedThe number of files that have downloaded successfully.
rslsFailedthe number of files that have failed to download.
rslsTotalthe total number of files that have downloaded, successfully or not.
failedURLsAn array of files that have failed to download.
         import fl.events.RSLErrorEvent;
         myPreloader.addEventListener(RSLErrorEvent.RSL_LOAD_FAILED, rslLoadFailedHandler);
         function rslLoadFailedHandler(e:RSLErrorEvent) {
         gotoAndPlay('rslLoadFailure');
         }
         

rslProgress

Event  
Event Object Type: fl.events.RSLEvent
property RSLEvent.type = fl.events.RSLEvent.RSL_PROGRESS

Language Version: ActionScript 3.0
Product Version: Flash CS5
Runtime Versions: Flash Player 10.1, AIR 2

Dispatched by RSLPreloader to indicate progress in downloading RSL files.

Event dispatched by RSLPreloader to indicate progress in downloading RSL files. This is the only event type for which the bytesLoaded and bytesTotal properties are non-zero.

This event has the following properties:

PropertyValue
bubblestrue
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe DisplayObject instance being added to the display list. The target is not always the object in the display list that registered the event listener. Use the currentTarget property to access the object in the display list that is currently processing the event.
rslsLoadedThe number of files that have downloaded successfully.
rslsFailedthe number of files that have failed to download.
rslsTotalthe total number of files that have downloaded, successfully or not.
bytesLoadedThe total number of downloaded bytes in files that have successfully downloaded.
bytesTotalthe total number of downloaded bytes in files that have downloaded, successful or not.
         import fl.events.RSLEvent;
         myPreloader.addEventListener(RSLEvent.RSL_PROGRESS, progressHandler);
         function progressHandler(e:RSLEvent) {
         trace('rslsLoaded = ' + e.rslsLoaded);
         trace('rslsFailed = ' + e.rslsFailed);
         trace('rslsTotal = ' + e.rslsTotal);
         trace('bytesLoaded = ' + e.bytesLoaded);
         trace('bytesTotal = ' + e.bytesTotal);
         }