Skip to content

Instantly share code, notes, and snippets.

@jgranick
Created September 27, 2013 16:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgranick/6731548 to your computer and use it in GitHub Desktop.
Save jgranick/6731548 to your computer and use it in GitHub Desktop.
Adding a Custom Asset Library
package;
import flash.utils.ByteArray;
import openfl.Assets;
class CustomAssetLibrary extends AssetLibrary {
public function new () {
super ();
}
public override function exists (id:String, type:AssetType):Bool {
if (type == BINARY && id == "hello") {
return true;
}
return false;
}
public override function getBytes (id:String):ByteArray {
var bytes = new ByteArray ();
bytes.writeUTFBytes ("Hello World");
bytes.position = 0;
return bytes;
}
}
package;
import flash.display.Sprite;
import openfl.Assets;
class Main extends Sprite {
public function new () {
super ();
Assets.registerLibrary ("test", new CustomAssetLibrary ());
trace (Assets.getText ("test:hello"));
}
}
@mustafaozcaninfo
Copy link

Mustafa Özcan

Kişisel Blog makalelerimi SEO konusundaki deneyimleri paylaştığım blogum.Fırsatları ayağınıza getiren mustafa ozcan blog kişisel temalı yazılar ile gündemde yer alan güncel yazıları sizlere sunma fırsatı ile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment