refactor node stateClasses and stylelist calculation
[potlatch2.git] / net / systemeD / potlatch2 / mapfeatures / editors / Choice.as
index b501b196a1062bfa759ddd78b34b4413ad504ec2..2b390c1bbc6c900110b5e3ba91a4c5f4aa1d5ea4 100644 (file)
@@ -1,53 +1,24 @@
 package net.systemeD.potlatch2.mapfeatures.editors {
 
     import flash.events.*;
+    import flash.utils.ByteArray;
 
        public class Choice extends EventDispatcher {
 
-        private var _label:String = "";
-        private var _description:String = "";
-        private var _value:String = null;
-        private var _icon:String = null;
-        private var _match:RegExp = null;
-        
-        [Bindable(event="valueChange")]
-        public function get label():String { return _label; }
-
-        [Bindable(event="valueChange")]
-        public function get description():String { return _description; }
-
-        [Bindable(event="valueChange")]
-        public function get value():String { return _value; }
+        [Bindable]
+        public var label:String = "";
+        [Bindable]
+        public var description:String = "";
+        [Bindable]
+        public var value:String = null;
+        [Bindable(event="iconLoaded")]
+        public var icon:ByteArray = null;
 
-        [Bindable(event="valueChange")]
-        public function get icon():String { return _icon; }
-
-        public function set label(l:String):void {
-            _label = l;
-            dispatchEvent(new Event("valueChange"));
-        }
-        
-        public function set description(l:String):void {
-            _description = l;
-            dispatchEvent(new Event("valueChange"));
-        }
-        
-        public function set value(l:String):void {
-            _value = l;
-            dispatchEvent(new Event("valueChange"));
-        }
-        
-        public function set icon(l:String):void {
-            _icon = l;
-            dispatchEvent(new Event("valueChange"));
-        }
+        private var _match:RegExp = null;
         
         public function isTagMatch(tagValue:String):Boolean {
             if ( _match == null )
-                return tagValue == _value;
-            //_match.lastIndex = 0;
-            //var result:Object = _match.exec(tagValue);
-            //return result != null && result.index == 0 && _match.lastIndex == tagValue.length;
+                return tagValue == value;
             return _match.test(tagValue);
         }
         
@@ -56,6 +27,11 @@ package net.systemeD.potlatch2.mapfeatures.editors {
                 _match = new RegExp("^("+matchStr+")$");
             }
         }
+        
+        public function imageLoaded(url:String, data:ByteArray):void {
+            icon = data;
+            dispatchEvent(new Event("iconLoaded"));
+        }
     }
 
 }