Make paintContainer private, and add a method to access all MapPaint objects
authorAndy Allan <andy@gravitystorm.co.uk>
Tue, 24 May 2011 13:10:56 +0000 (14:10 +0100)
committerAndy Allan <andy@gravitystorm.co.uk>
Tue, 24 May 2011 13:10:56 +0000 (14:10 +0100)
net/systemeD/halcyon/Map.as
net/systemeD/potlatch2/VectorSourceDialog.mxml

index 1c79093..9dcb118 100644 (file)
@@ -29,7 +29,7 @@ package net.systemeD.halcyon {
                public const MAXSCALE:uint=23; 
 
                // Container for MapPaint objects
-               public var paintContainer:Sprite;
+               private var paintContainer:Sprite;
 
                /** map scale */
                public var scale:uint=14;                                                
@@ -269,6 +269,16 @@ package net.systemeD.halcyon {
                private function getLayerAt(i:uint):MapPaint {
                        return MapPaint(paintContainer.getChildAt(i));
                }
+
+        /** Get all the layers available for this Map object
+        *   @return An array of MapPaint objects */
+        public function getLayers():Array {
+            var a:Array = [];
+            for (var i:uint=0; i<paintContainer.numChildren; i++) {
+                a.push(getLayerAt(i));
+            }
+            return a;
+        }
                
                /* Find which layer is editable */
                public function get editableLayer():MapPaint {
index 5f6b85b..33948eb 100644 (file)
        [Bindable(event="layers_changed")]
        private function get vectorLayers():Array {
         var v:Array=[];
-        for (var i:uint = 0; i < map.paintContainer.numChildren; i++) { //nasty
-            var a:MapPaint = MapPaint(map.paintContainer.getChildAt(i));
+        for each (var a:MapPaint in map.getLayers() ) {
             if (a.isBackground) {
                 v.push( { name:a.connection.name, visible:a.visible, url:a.connection.apiBase, style:a.style } );
             }
-               }
+        }
                return v;
        }