Skip to content

Instantly share code, notes, and snippets.

@k0t0vich
Created March 12, 2013 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k0t0vich/5141979 to your computer and use it in GitHub Desktop.
Save k0t0vich/5141979 to your computer and use it in GitHub Desktop.
private function decode(async: Boolean = true):void {
if (_decoded)
return;
_lenght = _bundle.atfTextures.length;
_counter = 0;
var me: StarlingWrapper = this;
for (var i: int = 0; i < _lenght; i++) {
var atf: ByteArray = _bundle.atfTextures[i];
if (async) {
Texture.fromAtfData(atf, 1, true, createCallBack(i, atf));
} else {
var texture: Texture = Texture.fromAtfData(atf);
_starlingTextures.push(texture);
atf.clear();
}
}
}
private function createCallBack(i:int, atf:ByteArray):Function {
return function(texture: Texture):void {
_starlingTextures[i] = texture;
atf.clear();
_counter++;
if (_counter == _lenght) {
_decoded = true;
dispatchEvent(new Event(Event.COMPLETE));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment