use promise in loader

This commit is contained in:
2015-07-17 21:27:20 +03:00
parent 61b0078f3f
commit 18808764f9
14 changed files with 74 additions and 121 deletions

View File

@@ -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);
});
}