OSDN Git Service

add fromURL function. It use XHR
[flapp/flapp.git] / loader.js
1 (function(global) {
2     var FlappLoader = function() {
3     }
4     FlappLoader.prototype = {
5         fromURL: function(url, dict, movieClip) {
6             var xhr = new XMLHttpRequest();
7             var ibit = new FlappIBit();
8             var loader = this;
9             xhr.onreadystatechange = function() {
10                 if (xhr.readyState > 1) {
11                     if (xhr.status == 200) {
12                         if (xhr.responseText) {
13                             ibit.input(xhr.responseText);
14                             loader.parse(ibit, dict, movieClip);
15                         }
16                     }
17                 }
18             }
19             xhr.open('GET', url);
20             // xhr.responseType = 'arraybuffer';
21             xhr.overrideMimeType('text/plain; charset=x-user-defined');
22             xhr.send(null);
23         },
24         parse: function(ibit, dict, movieClip) {
25             
26         }
27     };
28     global.FlappLoader = FlappLoader;
29 })(this);