<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" horizontalAlign="center" initialize="init()">
    <mx:Script>
        <![CDATA[
        import mx.collections.ArrayCollection;
        import com.netthreads.traffic.model.TrafficModelLocator;
        
        [Bindable]
        public var model : TrafficModelLocator = TrafficModelLocator.getInstance();

        public static var TXT_SEVERITY_UNKNOWN:String = "unknown";
        public static var TXT_SEVERITY_VERYSLIGHT:String = "very slight";
        public static var TXT_SEVERITY_SLIGHT:String = "slight";
        public static var TXT_SEVERITY_MEDIUM:String = "medium";
        public static var TXT_SEVERITY_SEVERE:String = "severe";
        public static var TXT_SEVERITY_VERYSEVERE:String = "very severe";
        public static var TXT_SEVERITY_UNSPECIFIED:String = "unspecified";   

        private static var dict:Dictionary = null;
        
        private function init():void
        {
            if (dict==null)
            {
                dict = new Dictionary();
                
                dict[TXT_SEVERITY_UNKNOWN] = model.assets.transportPanelSlight;
                dict[TXT_SEVERITY_VERYSLIGHT] = model.assets.transportPanelSlight;
                dict[TXT_SEVERITY_SLIGHT] = model.assets.transportPanelSlight;
                dict[TXT_SEVERITY_UNSPECIFIED] = model.assets.transportPanelSlight;
                
                dict[TXT_SEVERITY_MEDIUM] = model.assets.transportPanelMedium;
                
                dict[TXT_SEVERITY_SEVERE] = model.assets.transportPanelSevere;
                dict[TXT_SEVERITY_VERYSEVERE] = model.assets.transportPanelSevere;
            }
        }
        
        /**
        * Return appropriate severity icon based on severity string.
        * Note: Uses static lookup table to hold mappings.
        * 
        */        
        public function getSeverityIcon(severity:String):Class
        {
            var result : Class = null;
        
            result = dict[severity];
            if (result==null)
            {
                result = model.assets.transportPanelSlight;
            }
            
            return result;	
        }
        
        ]]>
    </mx:Script>
    
    <mx:Image width="20" height="34" source="{getSeverityIcon(data.severity) }"/>

</mx:VBox>
