Skip to content

Instantly share code, notes, and snippets.

@bmfs
Last active February 21, 2017 23:07
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmfs/18caf119cfc6bfeff5fd to your computer and use it in GitHub Desktop.
Save bmfs/18caf119cfc6bfeff5fd to your computer and use it in GitHub Desktop.
Luxe: Load image from url
import luxe.Input;
import luxe.Sprite;
import luxe.Vector;
import snow.system.assets.Asset;
import snow.types.Types;
class Main extends luxe.Game {
override function ready() {
var url:String = "http://scontent-mad1-1.xx.fbcdn.net/hphotos-xal1/v/t1.0-9/10476456_974327349259161_6532508402920794869_n.jpg?oh=8a88384cc8b2f21878a09f9fe155cde9&oe=56DEF4A6";
Luxe.snow.io.data_load(url).then(handleData).error(handleError);
} //ready
function handleData(image){
var _load = Luxe.snow.assets.image_from_bytes("urlimage", image);
_load.then(function(asset:AssetImage) {
init(asset);
});
trace("got image");
}
function handleError(err){
trace("error loading image:" + err);
}
function init(asset:AssetImage)
{
trace("initing!");
var tex = new phoenix.Texture({
id: "urlimage",
width: asset.image.width_actual,
height: asset.image.height_actual,
pixels: asset.image.pixels
});
var detail_top = new Sprite({
texture: tex,
pos: new Vector(Luxe.screen.mid.x, Luxe.screen.mid.y),
depth: 1,
scale: new Vector(0.5, 0.5)
});
}
override function onkeyup( e:KeyEvent ) {
if(e.keycode == Key.escape) {
Luxe.shutdown();
}
} //onkeyup
override function update(dt:Float) {
} //update
} //Main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment