fix some random bugs + do something a bit cooler with maxspeed
[potlatch2.git] / net / systemeD / potlatch2 / mapfeatures / editors / Choice.as
1 package net.systemeD.potlatch2.mapfeatures.editors {
2
3     import flash.events.*;
4
5         public class Choice extends EventDispatcher {
6
7         private var _label:String = "";
8         private var _description:String = "";
9         private var _value:String = null;
10         private var _icon:String = null;
11         private var _match:RegExp = null;
12         
13         [Bindable(event="valueChange")]
14         public function get label():String { return _label; }
15
16         [Bindable(event="valueChange")]
17         public function get description():String { return _description; }
18
19         [Bindable(event="valueChange")]
20         public function get value():String { return _value; }
21
22         [Bindable(event="valueChange")]
23         public function get icon():String { return _icon; }
24
25         public function set label(l:String):void {
26             _label = l;
27             dispatchEvent(new Event("valueChange"));
28         }
29         
30         public function set description(l:String):void {
31             _description = l;
32             dispatchEvent(new Event("valueChange"));
33         }
34         
35         public function set value(l:String):void {
36             _value = l;
37             dispatchEvent(new Event("valueChange"));
38         }
39         
40         public function set icon(l:String):void {
41             _icon = l;
42             dispatchEvent(new Event("valueChange"));
43         }
44         
45         public function isTagMatch(tagValue:String):Boolean {
46             if ( _match == null )
47                 return tagValue == _value;
48             //_match.lastIndex = 0;
49             //var result:Object = _match.exec(tagValue);
50             //return result != null && result.index == 0 && _match.lastIndex == tagValue.length;
51             return _match.test(tagValue);
52         }
53         
54         public function set match(matchStr:String):void {
55             if ( matchStr != null && matchStr != "" ) {
56                 _match = new RegExp("^("+matchStr+")$");
57             }
58         }
59     }
60
61 }
62
63