+ Reply to Thread
Results 1 to 4 of 4

Thread: Attributes Help!

  1. #1
    ann tobias
    Join Date
    Mar 2012
    Posts
    9
    Points
    0
    Answers Provided
    0


    0

    Unhappy Attributes Help!

    I want to access my attributes in my xml file like this one.
    Code:
    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[i].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 attrib is displayed in an infowindow. How can I access my other variables to be displayed to another view? Please help..

  2. #2
    Ivan Bespalov
    Join Date
    Apr 2010
    Posts
    334
    Points
    306
    Answers Provided
    51


    0
    This post is marked as the answer

    Default Re: Attributes Help!

    Ann,

    Code:
    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));    
    }
    Last edited by ibespalov; 03-26-2012 at 01:34 AM.
    Ivan

    Samples

  3. #3
    ann tobias
    Join Date
    Mar 2012
    Posts
    9
    Points
    0
    Answers Provided
    0


    0

    Default 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..

    Code:
    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);
    			}

  4. #4
    Ivan Bespalov
    Join Date
    Apr 2010
    Posts
    334
    Points
    306
    Answers Provided
    51


    0

    Default Re: Attributes Help!

    How can I pass my attributes to another view?
    http://forums.arcgis.com/threads/534...ta-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
    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.
    Last edited by ibespalov; 03-26-2012 at 05:39 AM. Reason: links added
    Ivan

    Samples

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts