LoadItem Class
All loaders accept an item containing the properties defined in this class. If a raw object is passed instead, it will not be affected, but it must contain at least a Src:property property. A string path or HTML tag is also acceptable, but it will be automatically converted to a LoadItem using the Create method by AbstractLoader
Constructor
LoadItem
()
Item Index
Properties
Methods
create
-
value
Create a LoadItem.
- String-based items are converted to a LoadItem with a populated Src:property.
- LoadItem instances are returned as-is
- Objects are returned with any needed properties added
set
-
props
Provides a chainable shortcut method for setting a number of properties on the instance.
Example
var loadItem = new createjs.LoadItem().set({src:"image.png", maintainOrder:true});
Parameters:
-
props
ObjectA generic object containing properties to copy to the LoadItem instance.
Returns:
Returns the instance the method is called on (useful for chaining calls.)
Properties
callback
String
A callback used by JSONP requests that defines what global method to call when the JSONP content is loaded.
Default: null
crossOrigin
Boolean
Sets the crossOrigin attribute for CORS-enabled images loading cross-domain.
Default: Anonymous
headers
Object
An object hash of headers to attach to an XHR request. PreloadJS will automatically attach some default headers when required, including "Origin", "Content-Type", and "X-Requested-With". You may override the default headers by including them in your headers object.
Default: null
id
String
A string identifier which can be used to reference the loaded object. If none is provided, this will be automatically set to the Src:property.
Default: null
LOAD_TIMEOUT_DEFAULT
Number
static
Default duration in milliseconds to wait before a request times out. This only applies to tag-based and and XHR (level one) loading, as XHR (level 2) provides its own timeout event.
loadTimeout
Number
The duration in milliseconds to wait before a request times out. This only applies to tag-based and and XHR (level one) loading, as XHR (level 2) provides its own timeout event.
Default: 8000 (8 seconds)
maintainOrder
Boolean
Determines if a manifest will maintain the order of this item, in relation to other items in the manifest
that have also set the maintainOrder
property to true
. This only applies when the max connections has
been set above 1 (using setMaxConnections). Everything with this
property set to false
will finish as it is loaded. Ordered items are combined with script tags loading in
order when maintainScriptOrder is set to true
.
Default: false
method
String
The request method used for HTTP calls. Both GET or POST request types are supported, and are defined as constants on AbstractLoader.
Default: GET
mimeType
String
Set the mime type of XHR-based requests. This is automatically set to "text/plain; charset=utf-8" for text based files (json, xml, text, css, js).
Default: null
src
String
The source of the file that is being loaded. This property is required. The source can either be a string (recommended), or an HTML tag. This can also be an object, but in that case it has to include a type and be handled by a plugin.
Default: null
type
String
The type file that is being loaded. The type of the file is usually inferred by the extension, but can also be set manually. This is helpful in cases where a file does not have an extension.
Default: null