Created
September 27, 2013 16:51
-
-
Save jgranick/6731548 to your computer and use it in GitHub Desktop.
Adding a Custom Asset Library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.