-
Notifications
You must be signed in to change notification settings - Fork 22
/
WebBundleTest.hx
55 lines (44 loc) · 1014 Bytes
/
WebBundleTest.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package;
import js.Browser;
import js.Bundle;
import js.html.Element;
import js.html.Image;
/**
*
* @author Eduardo Pons - [email protected]
*/
class WebBundleTest
{
/**
* Entry point.
*/
static public function main():Void
{
trace("WebBundle> Haxe Example");
//creates an empty Bundle.
var b : Bundle = new Bundle();
//Loads an example bundle from the data folder.
b.load("data/resource-pass.wb",function(d:Bundle,p:Float)
{
//check load progress.
trace(p);
//if 100%
if(p>=1)
{
//if data is valid.
if(d==null)return;
//reads an image from the 'portrait.jpg' byte buffer.
d.readImg("portrait.png",function(img:Image)
{
Browser.document.body.appendChild(img);
});
//loads a json string.
trace(d.readText("data.json"));
//loads a json parsed string.
trace(d.readJSON("data.json"));
//loads a XML string.
trace(d.readText("xml.dae").substr(0,500));
}
},"12345");
}
}