Removed executable flag from files which don't need it.
[potlatch2.git] / net / systemeD / potlatch2 / mapfeatures / Feature.as
index 69a1dfb8af621ac1e5b5345c91da8750798e8116..0ad71358eeab6050181ffff3ced5bed50e1a5c01 100644 (file)
@@ -4,6 +4,8 @@ package net.systemeD.potlatch2.mapfeatures {
     import flash.events.Event;
     import flash.net.*;
     import flash.utils.ByteArray;
+    import mx.core.BitmapAsset;
+    import mx.graphics.codec.PNGEncoder;
     
     import net.systemeD.halcyon.connection.Entity;
     import net.systemeD.potlatch2.utils.CachedDataLoader;
@@ -16,6 +18,11 @@ package net.systemeD.potlatch2.mapfeatures {
                private var _withins:Array;
         private var _editors:Array;
 
+        [Embed(source="../../../../embedded/missing_icon.png")]
+        [Bindable]
+        public var missingIconCls:Class;
+
+
         public function Feature(mapFeatures:MapFeatures, _xml:XML) {
             this.mapFeatures = mapFeatures;
             this._xml = _xml;
@@ -95,14 +102,19 @@ package net.systemeD.potlatch2.mapfeatures {
         public function get image():ByteArray {
             var icon:XMLList = _xml.icon;
             var imageURL:String = null;
+            var img:ByteArray;
 
             if ( icon.length() > 0 && icon[0].hasOwnProperty("@image") )
                 imageURL = icon[0].@image;
-            
+
             if ( imageURL != null ) {
-                return CachedDataLoader.loadData(imageURL, imageLoaded);
+                img = CachedDataLoader.loadData(imageURL, imageLoaded);
             }
-            return null;
+            if (img) {
+              return img;
+            }
+            var bitmap:BitmapAsset = new missingIconCls() as BitmapAsset;
+            return new PNGEncoder().encode(bitmap.bitmapData);
         }
         
         private function imageLoaded(url:String, data:ByteArray):void {