use promise in loader
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
-cp src
|
||||
-lib promhx
|
||||
-lib haxework
|
||||
-main LoaderExample.hx
|
||||
-swf-version 10.1
|
||||
|
||||
@@ -19,24 +19,24 @@ class LoaderExample {
|
||||
// Json
|
||||
trace("Json Request");
|
||||
new JsonLoader().GET("http://umix.tv/channel/data2/renova.json")
|
||||
.success(function(channel:Array<ChannelItem>) {
|
||||
.then(function(channel:Array<ChannelItem>) {
|
||||
trace("Json Ok: " + channel.length);
|
||||
for (item in channel) {
|
||||
trace(item.id + ": " + item.message);
|
||||
}
|
||||
})
|
||||
.fail(function(error) {
|
||||
.catchError(function(error) {
|
||||
trace(error);
|
||||
});
|
||||
|
||||
// Image
|
||||
trace("Image Request");
|
||||
new ImageLoader().GET("http://umix.tv/channel/block/renova/1")
|
||||
.success(function(image:BitmapData) {
|
||||
.then(function(image:BitmapData) {
|
||||
trace("Image Ok: " + image.width + "x" + image.height);
|
||||
Lib.current.addChild(new Bitmap(image));
|
||||
})
|
||||
.fail(function(error) {
|
||||
.catchError(function(error) {
|
||||
trace(error);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user