o3d.FileRequest Class Reference
Inherits
o3d.ObjectBase
List of all members.
Detailed Description
A FileRequest is used to carry out an asynchronous request for a file
to be loaded. Its use parallels that of XMLHttpRequest; you create one, call
open, set the onreadystatechange callback, and call send.
Note that unlike XMLHttpRequests, FileRequests cannot be reused.
For RawData loads, on success the RawData will be stored in the data field
on the FileRequest itself. It is only valid until the FileRequest is freed by
calling pack.removeObject(request).
var request = pack.createFileRequest("RAWDATA");
request.open("GET", url, true);
request.onreadystatechange = function() {
if (request.done) {
if (request.success) {
var rawData = request.data;
// do something with raw data like create a bitmap.
...
} else {
dump('Load of rawdata returned failure.');
}
// Free the request (and the rawData)
pack.removeObject(request);
}
};
request.send();
Public Member Functions
Public Properties
Member Function Documentation
| boolean FileRequest.isAClassName |
( |
string |
className |
) |
[inherited from o3d.ObjectBase] |
Takes the name of a class as an argument, and returns true if this object is
either an instance of that class or derives from that class.
var t = pack.createObject('o3d.Transform');
t.isAClassName('o3d.Transform'); // true
t.isAClassName('o3d.ParamObject'); // true
t.isAClassName('o3d.Shape'); // false
- Parameters:
-
| className |
Name of class to check for. |
- Returns:
-
boolean.true if this object is a or is derived from the given class name.
| FileRequest.open |
( |
string |
method |
|
|
|
|
string |
uri |
|
|
|
|
boolean |
async |
) |
|
Set up several of the request fields.
- Parameters:
-
| method |
"GET" is the only supported method at this time |
| uri |
the location of the file to fetch |
| async |
true is the only legal value at this time |
Send the request.
Unlike XMLHttpRequest the onreadystatechange callback will be called no
matter what, with success or failure.
Member Property Documentation
The concrete class name for an object derived from ObjectBase.
If you want to know if an object is of a certain type you should use
objectBase.isAClassName
var t = pack.createObject('o3d.Transform');
t.className == 'o3d.Transform'; // true
This property is read-only.
Unique id of the object.
This id will be unique, even across multiple O3D clients in the same
page.
This property is read-only.
On completion of successful RawData file loads, this holds the loaded
RawData.
This property is read-only.
This indicates whether any further processing will be done on this
FileRequest.
This property is read-only.
An error message.
If done is true and success is false this will be an error message
describing what went wrong.
This property is read-only.
| boolean FileRequest.generateMipmaps
[**DEPRECATED**]
|
Whether or not to generate mip-maps on textures that are loaded (default:
true). Mip-maps are not generated for DXTC textures. DDS files can contain
pre-computed mip-maps for DXTC textures though.
Loading textures through FileRequest is depreated.
| function(): void FileRequest.onreadystatechange
|
A callback to call whenever the ready state of the request changes.
This property is write-only.
| number FileRequest.readyState
|
This holds the same values as in XMLHttpRequest:
0 = uninitialized
1 = opened
2 = sent
3 = receiving
4 = loaded (the file has been downloaded, but may or may not have been
parsed yet)
This property is read-only.
| boolean FileRequest.success
|
This field is only valid if done is true. It indicates whether or not the
request succeeded. If it failed error holds an error message.
This property is read-only.
On completion of successful texture file loads, this holds the loaded
texture. Loading textures through FileRequest is depreated.
The URI this request is for.
This property is read-only.