Attributes Help!

521
3
Jump to solution
03-26-2012 12:51 AM
sherlytobias
New Contributor
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.name;      var r:Object = pntList.region;      var s:Object = pntList.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 attrib is displayed in an infowindow. How can I access my other variables to be displayed to another view? Please help..
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
IvanBespalov
Occasional Contributor III
Ann,

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.point.split(" ");                  //create graphic attributes         var attributes:Object = new Object();         attributes.name = pntList.name; // attributes["name"]         attributes.region = pntList.region; // attributes["region"]         attributes.summary = pntList.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));     }

View solution in original post

0 Kudos
3 Replies
IvanBespalov
Occasional Contributor III
Ann,

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.point.split(" ");                  //create graphic attributes         var attributes:Object = new Object();         attributes.name = pntList.name; // attributes["name"]         attributes.region = pntList.region; // attributes["region"]         attributes.summary = pntList.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));     }
0 Kudos
sherlytobias
New Contributor
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);
    vbox.addChild(button);
   
    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
   { 
    
    navigator.pushView(newView);
   }
   
   
0 Kudos
IvanBespalov
Occasional Contributor III
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.

Right?
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.
0 Kudos