44 lines
1.0 KiB
Haxe
Executable File
44 lines
1.0 KiB
Haxe
Executable File
package;
|
|
|
|
import flash.display.Bitmap;
|
|
import flash.Lib;
|
|
import flash.display.BitmapData;
|
|
import haxework.net.ImageLoader;
|
|
import haxework.net.JsonLoader;
|
|
|
|
typedef ChannelItem = {
|
|
var id:String;
|
|
var maker:String;
|
|
var title:String;
|
|
var message:String;
|
|
}
|
|
|
|
class LoaderExample {
|
|
|
|
public static function main() {
|
|
// Json
|
|
trace("Json Request");
|
|
new JsonLoader().GET("http://umix.tv/channel/data2/renova.json")
|
|
.then(function(channel:Array<ChannelItem>) {
|
|
trace("Json Ok: " + channel.length);
|
|
for (item in channel) {
|
|
trace(item.id + ": " + item.message);
|
|
}
|
|
})
|
|
.catchError(function(error) {
|
|
trace(error);
|
|
});
|
|
|
|
// Image
|
|
trace("Image Request");
|
|
new ImageLoader().GET("http://umix.tv/channel/block/renova/1")
|
|
.then(function(image:BitmapData) {
|
|
trace("Image Ok: " + image.width + "x" + image.height);
|
|
Lib.current.addChild(new Bitmap(image));
|
|
})
|
|
.catchError(function(error) {
|
|
trace(error);
|
|
});
|
|
}
|
|
}
|