3 Replies Latest reply: Mar 26, 2012 2:45 AM by ibespalov

    Attributes Help!

      I want to access my attributes in my xml file like this one.
      protected function pointsXML_resultHandler(event:ResultEvent):void    {     var gArr:Array = [];     var myGraphics:Array = [];          var x:XML = XML(event.result);     pntList = x..entry;     for (var i:int = 0; i < pntList.length(); i++){      var latlong:Array = pntList.point.split(" ");      var attrib:Object = pntList[i].name;      var r:Object = pntList[i].region;      var s:Object = pntList[i].summary;            var myPoint:Geometry = new MapPoint(latlong[1], latlong[0], new SpatialReference(4326));            var coordGraphic:Graphic = new Graphic(myPoint,null,attrib);            gArr.push(myPoint);      myGraphics.push(coordGraphic);           }     var outSR:SpatialReference = new SpatialReference(3857);     geometryService.project(gArr, outSR, new AsyncResponder(projectCompleteHandler, null, myGraphics));        }

      the variable [I]attrib is displayed in an infowindow. How can I access my other variables to be displayed to another view? Please help..
        • Re: Attributes Help!

          protected function pointsXML_resultHandler(event:ResultEvent):void {     var inSr:SpatialReference = new SpatialReference(4326);     var outSr:SpatialReference = new SpatialReference(3857);      var gArr:Array = new Array();     var myGraphics:Array = new Array();          var x:XML = XML(event.result);     pntList = x..entry;     for (var i:int; i < pntList.length(); i++)     {         var latlong:Array = pntList[i].point.split(" ");                  //create graphic attributes         var attributes:Object = new Object();         attributes.name = pntList[i].name; // attributes["name"]         attributes.region = pntList[i].region; // attributes["region"]         attributes.summary = pntList[i].summary; // attributes["summary"] // you can hold/add/remove/read/... on client side any attribute types you want         attributes.myBool = false; // type Boolean         attributes.creationDate = new Date(); // type date         attributes.myComplexAttribute = new MyComplexAttribute();          attributes.symbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.CIRCLE, ...);               var myPoint:Geometry = new MapPoint(latlong[1], latlong[0], inSr);  var coordGraphic:Graphic = new Graphic(myPoint, null, attributes);  gArr.push(myPoint);  myGraphics.push(coordGraphic);     }      geometryService.project(gArr, outSR, new AsyncResponder(onProjectComplete, onProjectFault, myGraphics));     }
          • Re: Attributes Help!
            Thank you! But I have one more question. How can I pass my attributes to another view? I don't have any idea on what to put in my EventListener, click. This is a mobile application. Any help? Please.. :(

            private function mClick(event:MouseEvent):void
                var gra:Graphic = event.target as Graphic;
                var vbox:VBox = new VBox();
                vbox.height = 40;
                vbox.width = 170;
                vbox.label = gra.attributes.name.toString();
                var button:Button = new Button();
                button.height = 40;
                button.width = 170;
                button.label = gra.attributes.region.toString();
                button.addEventListener(MouseEvent.CLICK, click);
                map.infoWindow.content = vbox;
                map.infoWindow.closeButton.height = 15;
                map.infoWindow.closeButton.width = 15;
                map.infoWindow.show(gra.geometry as MapPoint);
                                          private function click(event:MouseEvent):void
            • Re: Attributes Help!
              How can I pass my attributes to another view?

              http://forums.arcgis.com/threads/53425-Passing-data-to-new-view - this thread?

              1 - You have >1 views in your app.
              2 - Your app is mobile app.
              3 - Clicking in some view you need to handle it in another view.

              Looks like puzzle or charade :confused:
              Let me try:

              1(both views are opened at the same time) - You can bind data to your second view (adobe help).
              2(both views have access to object) - You can't bind data, but you have reference to some object (layer or/and graphic) in both views.

              • Each time, you add somthing to your graphics layer you can handle graphicAdd handler. - you access to each graphic added to layer;

              • When you have access to graphic add listener to it (change, click, over, out ....);

              3(flex mobile) - Read adobe help carefully, search samples (Passing data between Views) in adobe site, search samples (Understanding Flex Mobile View and ViewNavigator) in web.
              If you want to pass some data from one view to another (for example an ArrayCollection or some other Data Model), then you can use the second argument of the navigator.pushView() method:
              navigator.pushView(SecondScreen, myData);

              P.S. Reproduction of 1 question to multiple threads is bad idea, remove duplicates.