Merge branch 'master' of github.com:systemed/potlatch2
[potlatch2.git] / net / systemeD / potlatch2 / mapfeatures / editors / Choice.as
1 package net.systemeD.potlatch2.mapfeatures.editors {
2
3     import flash.events.*;
4     import flash.utils.ByteArray;
5     import net.systemeD.halcyon.FileBank;
6
7         public class Choice extends EventDispatcher {
8
9         [Bindable]
10         public var label:String = "";
11         [Bindable]
12         public var description:String = "";
13         [Bindable]
14         public var value:String = null;
15         [Bindable(event="iconLoaded")]
16         public var icon:ByteArray = null;
17
18         private var _match:RegExp = null;
19         
20         public function isTagMatch(tagValue:String):Boolean {
21             if ( _match == null )
22                 return tagValue == value;
23             return _match.test(tagValue);
24         }
25         
26         public function set match(matchStr:String):void {
27             if ( matchStr != null && matchStr != "" ) {
28                 _match = new RegExp("^("+matchStr+")$");
29             }
30         }
31
32         public function imageLoaded(fileBank:FileBank, name:String):void {
33             icon = fileBank.getAsByteArray(name);
34             dispatchEvent(new Event("iconLoaded"));
35         }        
36     }
37 }