OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010, Google Inc. | 2 * Copyright 2010, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 17 matching lines...) Expand all Loading... |
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 */ | 30 */ |
31 | 31 |
32 | 32 |
33 /** | 33 /** |
34 * A FileRequest is used to carry out an asynchronous request for a file | 34 * A FileRequest is used to carry out an asynchronous request for a file |
35 * to be loaded. Its use parallels that of XMLHttpRequest; you create one, call | 35 * to be loaded. Its use parallels that of XMLHttpRequest; you create one, call |
36 * open, set the onreadystatechange callback, and call send. | 36 * open, set the onreadystatechange callback, and call send. |
37 * Note that unlike XMLHttpRequests, FileRequests cannot be reused. | 37 * Note that unlike XMLHttpRequests, FileRequests cannot be reused. |
38 * | 38 * |
39 * For RawData loads, on success the RawData will be stored in the data field | 39 * For RawData loads, on success the RawData will be stored in the data field |
40 * on the FileRequest itself. It is only valid until the FileRequest is freed by | 40 * on the FileRequest itself. It is only valid until the FileRequest is freed by |
41 * calling pack.removeObject(request). | 41 * calling pack.removeObject(request). |
42 * | 42 * |
43 * var request = pack.createFileRequest("RAWDATA"); | 43 * var request = pack.createFileRequest("RAWDATA"); |
44 * request.open("GET", url, true); | 44 * request.open("GET", url, true); |
45 * request.onreadystatechange = function() { | 45 * request.onreadystatechange = function() { |
46 * if (request.done) { | 46 * if (request.done) { |
47 * if (request.success) { | 47 * if (request.success) { |
48 * var rawData = request.data; | 48 * var rawData = request.data; |
49 * | 49 * |
50 * ... | 50 * ... |
51 * } else { | 51 * } else { |
52 * dump('Load of rawdata returned failure.'); | 52 * dump('Load of rawdata returned failure.'); |
53 * } | 53 * } |
54 * | 54 * |
55 * pack.removeObject(request); | 55 * pack.removeObject(request); |
56 * } | 56 * } |
57 * }; | 57 * }; |
58 * request.send(); | 58 * request.send(); |
59 */ | 59 */ |
60 o3d.FileRequest = function() { | 60 o3d.FileRequest = function() { |
61 this.method_ = ""; | 61 this.method_ = ""; |
62 this.async_ = true; | 62 this.async_ = true; |
63 this.request_ = new XMLHttpRequest(); | 63 this.request_ = new XMLHttpRequest(); |
64 var fileRequest = this; | 64 var fileRequest = this; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 that.imageLoaded_.call(that); | 207 that.imageLoaded_.call(that); |
208 } | 208 } |
209 this.image_.src = this.uri; | 209 this.image_.src = this.uri; |
210 } else { | 210 } else { |
211 this.request_.open(this.method_, this.uri, this.async_); | 211 this.request_.open(this.method_, this.uri, this.async_); |
212 } | 212 } |
213 }; | 213 }; |
214 | 214 |
215 | 215 |
216 | 216 |
OLD | NEW |