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:
@@ -93,11 +93,16 @@ public class TileDataPack extends DataPack
|
|||||||
|
|
||||||
if (_cache.containsKey(key)) {
|
if (_cache.containsKey(key)) {
|
||||||
callback(_cache.get(key));
|
callback(_cache.get(key));
|
||||||
|
} else if (_pending.containsKey(key)) {
|
||||||
|
_pending.get(key).push(callback);
|
||||||
} else {
|
} else {
|
||||||
|
_pending.put(key, [callback]);
|
||||||
MultiLoader.getContents(PngRecolorUtil.recolorPNG(getFile(path), zations),
|
MultiLoader.getContents(PngRecolorUtil.recolorPNG(getFile(path), zations),
|
||||||
function(result :Bitmap) :void {
|
function(result :Bitmap) :void {
|
||||||
_cache.put(key, result);
|
_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. */
|
/** Cache of images loaded from this data pack. */
|
||||||
protected var _cache :Map = Maps.newMapOf(String);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user