BiResourceLoader
This class is used to load different kinds of resources. There are basically 3 types of resources that this class can handle. The first 2 are script files and a code string. The third one is a genereal object described by an XML element and in this case an object is created using a BiXmlResourceParser.
When creating general objects a few special rules apply. If the created object is an event target the resource loader will listen to load and error events so that it can be notified by the object that it is loaded. If the object has a load() method that will be called if the object is not already loaded. To decide if the object is loaded the resource loader will use getLoaded() if available and if that isn't available it is assumed that the object is loaded (or does not require loading).
This class extends BiEventTarget and therefore all methods and fields available for BiEventTarget are also available for BiResourceLoader .
Constructor
new BiResourceLoader ( oScriptLoaderQueueConstructor )
Parameters
| Name | Type | Optional | Default | Descripton |
oScriptLoaderQueueConstructor | Object | This is the constructor if the script loader queue to use, default is BiScriptLoaderQueue |
Properties
| Name | Type | get | set | Descripton |
autoNameMapping | Boolean | ![]() | ![]() | When this is true any XML object that has an id attribute will create a global reference to the object created from this XML element. |
count | Number | ![]() | The number of added resources | |
loaded | Boolean | ![]() | Whether all resources have been loaded. | |
loadedCount | Number | ![]() | The number of finished loading resources. This includes inline scripts and general objects as well. | |
scriptLoaderQueueConstructor | Object | ![]() | The constructor of the script loaded queue, default is BiScriptLoaderQueue. |
Methods
| Name | Description |
abort | Stops the current loading |
addResource | Adds a resource that the resource loader will instantiate and load. |
addResourcesFromNode | This method is used to load resources by BiAdf and BiCustomClass. It loads resources defined as child nodes on a node. |
getResourceById | Returns the resource with the given id |
load | Starts the loading of the resource. The loading is done asynchronously so this will return immediately. When all resources are loaded the load event will fire. |
Events
| Name | Type | Bubbles | Descripton |
load | | Fires when all the resources have been loaded and executed | |
progress | | Fires every time one of the external resources have been loaded. This is useful for providing visual feedback. |
Static Methods
None.
Static Fields
None.
Remarks
None.
Method Details
abort
Stops the current loading
Syntax
object.abort ( ) Parameters
No arguments.
Return Type
void
addResource
Adds a resource that the resource loader will instantiate and load.
Syntax
object.addResource ( sType,oData,sId ) Parameters
| Name | Type | Optional | Default | Descripton |
sType | String | This is either one of the following 2 types or the name of the class to use to instantiate the object. If a class name is passed then the oData argument should be an XML element that is then used to describe the object.script - the oData is treated as URI of the script fileinlinescript - the oDate string is treated as the script code | ||
oData | Object | For script this should be the URI of the script file. This is URI is relative to the ADF file. For inlinescript this is the script code as a string. For a general object this should be an XML element that is then passed to a BiXmlResourceLoader which will instantiate the object. | ||
sId | String | Optional id to use to find the source using getResourceById. If a general object is used the id attribute in the XML element is used instead. |
Return Type
void
addResourcesFromNode
This method is used to load resources by BiAdf and BiCustomClass. It loads resources defined as child nodes on a node.
Syntax
object.addResourcesFromNode ( oNode ) Parameters
| Name | Type | Optional | Default | Descripton |
oNode | Node | DOM node to load children of. |
Return Type
void
getResourceById
Returns the resource with the given id
Syntax
object.getResourceById ( sId ) Parameters
| Name | Type | Optional | Default | Descripton |
sId | String | The id of the resource to lookup |
Return Type
Object
load
Starts the loading of the resource. The loading is done asynchronously so this will return immediately. When all resources are loaded the load event will fire.
Syntax
object.load ( ) Parameters
No arguments.
Return Type
void
