From 7e88fb825b60899d4a9e19497544ff06a9bb3ccd Mon Sep 17 00:00:00 2001 From: Mike Thomas Date: Thu, 15 Jul 2010 20:37:54 +0000 Subject: [PATCH] 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 --- src/as/com/threerings/media/tile/TileDataPack.as | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/as/com/threerings/media/tile/TileDataPack.as b/src/as/com/threerings/media/tile/TileDataPack.as index 843b9c06..1c9242f2 100644 --- a/src/as/com/threerings/media/tile/TileDataPack.as +++ b/src/as/com/threerings/media/tile/TileDataPack.as @@ -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); } } \ No newline at end of file