Load choice editor images through the FileBank
authorTom Hughes <tom@compton.nu>
Sat, 24 Mar 2012 12:45:18 +0000 (12:45 +0000)
committerTom Hughes <tom@compton.nu>
Sat, 24 Mar 2012 16:08:13 +0000 (16:08 +0000)
net/systemeD/potlatch2/mapfeatures/editors/Choice.as
net/systemeD/potlatch2/mapfeatures/editors/ChoiceEditorFactory.as

index 2b390c1..891da56 100644 (file)
@@ -27,11 +27,6 @@ package net.systemeD.potlatch2.mapfeatures.editors {
                 _match = new RegExp("^("+matchStr+")$");
             }
         }
-        
-        public function imageLoaded(url:String, data:ByteArray):void {
-            icon = data;
-            dispatchEvent(new Event("iconLoaded"));
-        }
     }
 
 }
index 6beaa3d..4cc1e0f 100644 (file)
@@ -2,8 +2,9 @@ package net.systemeD.potlatch2.mapfeatures.editors {
 
     import net.systemeD.halcyon.connection.*;
     import net.systemeD.potlatch2.mapfeatures.*;
-    import net.systemeD.potlatch2.utils.CachedDataLoader;
+    import net.systemeD.halcyon.FileBank;
     import flash.display.*;
+    import flash.events.*;
 
        public class ChoiceEditorFactory extends SingleTagEditorFactory {
            public var choices:Array;
@@ -12,14 +13,22 @@ package net.systemeD.potlatch2.mapfeatures.editors {
             super(inputXML,"horizontal");
             
             choices = [];
+
+            var fileBank:FileBank = FileBank.getInstance();
+            
             for each( var choiceXML:XML in inputXML.choice ) {
                 var choice:Choice = new Choice();
                 choice.value = String(choiceXML.@value);
                 choice.description = String(choiceXML.@description);
                 choice.label = String(choiceXML.@text);
-                choice.icon = choiceXML.hasOwnProperty("@icon") ? 
-                    CachedDataLoader.loadData(String(choiceXML.@icon), choice.imageLoaded) : null;
                 choice.match = String(choiceXML.@match);
+                if (choiceXML.hasOwnProperty("@icon")) {
+                    var icon:String = String(choiceXML.@icon);
+                    fileBank.addFromFile(icon, function (fb:FileBank, name:String):void {
+                        choice.icon = fb.getAsByteArray(name);
+                        choice.dispatchEvent(new Event("iconLoaded"));
+                    });
+                }
                 choices.push(choice);
             }
         }