Adobe Flex: Accessing Particular Field From XMLList

eddiecrosby

New Member
I currently have data that's returned from my database and has been stored in an XMLList. In the result handler from the database has a loop that puts markers on a Google Map, with custom icons depending on type. When I click the marker it opens an info window and displays HTML containing data from the XMLList. I also want the clicking of the marker to pass data to a label I have, but I can't seem to.Outside of this function I have declared the following:\[code\]var dict=new flash.utils.Dictionary();\[/code\]Here's the code I have so far:\[code\]protected function getBusiness_resultHandler(event:ResultEvent):void { var xml:XML = new XML(event.result as String); testList = xml.user;\[/code\]\[code\] for (var i:int=0; i<testList.length(); i++) { if (testList.type=="Hotel") { var bm:Bitmap = new Hotel as Bitmap; } else { var bm:Bitmap = new Hostel as Bitmap; } var html:String = "<b>" + testList.name + "</b><br/>" + testList.street + "<br/>" + testList.city + "<br/>" + testList.country + ", " + testList.postcode; var testMarker:Marker = new Marker(new LatLng(testList.latitude,testList.longitude), new MarkerOptions({icon:bm, iconOffset: new Point (-23, -44)})); testMarker.addEventListener(MapMouseEvent.CLICK, function(e:MapMouseEvent):void { Marker(e.currentTarget).openInfoWindow(new InfoWindowOptions({contentHTML:dict[e.currentTarget]})); }); dict[testMarker] = html; Map.addOverlay(testMarker); } }\[/code\]That code works, it just allows my to display all markers based on their latitude/longitude and then when I click the marker it displays the information correctly. Within the click function I have added \[code\]testLabel.text = testList.name;\[/code\] and it returned all of the XML tags, but I don't know how to access a specific one. I tried \[code\]testLabel.text = testList.name;\[/code\] and it gave an error saying \[code\]Error #1010: A term is undefined and has no properties\[/code\]. I also tried \[code\]testLabel.text = testList[e.currentTarget].name\[/code\] and nothing showed up in my label.I just don't understand how it can access the XML data for the info window when I click the marker, but not for the label. I don't fully understand the dict, but if it means it can only be used once and I have to choose between an info window and returning the function to the label, then I need it to go to the label.I'm really struggling here so I'm grateful for any help.
 
Back
Top