If we're in the middle of trying to load up one of our files, don't go and do it again, instead wait til it's done and just hear about it then.

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@955 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Mike Thomas
2010-07-15 20:37:54 +00:00
parent 3d70c731a5
commit 7e88fb825b
@@ -93,11 +93,16 @@ public class TileDataPack extends DataPack
if (_cache.containsKey(key)) {
callback(_cache.get(key));
} else if (_pending.containsKey(key)) {
_pending.get(key).push(callback);
} else {
_pending.put(key, [callback]);
MultiLoader.getContents(PngRecolorUtil.recolorPNG(getFile(path), zations),
function(result :Bitmap) :void {
_cache.put(key, result);
callback(result);
for each (var func :Function in _pending.remove(key)) {
func(result);
}
});
}
}
@@ -115,5 +120,8 @@ public class TileDataPack extends DataPack
/** Cache of images loaded from this data pack. */
protected var _cache :Map = Maps.newMapOf(String);
/** Any images we're in the process of resolving, map their key to a list of listeners*/
protected var _pending :Map = Maps.newMapOf(String);
}
}