Georgianna, What I meant by Look at the toolbar above the box you type in it will be the # button.
is that you have to use the code wrap option when you paste code in this forum or you will end up with smiles and just generally screwed up code.So here is what I was saying you need to click before you paste code:
Anyway here is the code with the errors fixed. I did not spend any time refactoring the code or doing any good general code clean-up though.<?xml version="1.0" encoding="utf-8"?>
<viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:viewer="com.esri.viewer.*"
xmlns:esri="http://www.esri.com/2008/ags"
x="600" y="300"
layout="absolute"
widgetConfigLoaded="init()" >
<fx:Script>
<![CDATA[
import com.esri.ags.FeatureSet;
import com.esri.ags.utils.GraphicUtil;
import com.esri.ags.geometry.Extent;
import mx.collections.ArrayList;
import mx.controls.Alert;
import mx.rpc.AsyncResponder;
import mx.events.EffectEvent;
import spark.components.supportClasses.ItemRenderer;
import spark.core.NavigationUnit;
private const BOOKMARKS:String = "bookmarks";
private const BOOKMARKS2:String = "bookmarks2";
private const ICON_URL:String = "assets/images/";
//labels
private var bookmarksLabel:String;
[Bindable]
//query info
private var featureURL:String;
private var queryAttribute:String;
private var featureURL2:String;
private var queryAttribute2:String;
[Bindable]
private var bookmarkAL:ArrayList; // used by BookmarkDataGroup
private var bookmarkSO:SharedObject;
private var bookmarkSOAL:ArrayList; // stored in bookmarkSO
[Bindable]
private var bookmarkAL2:ArrayList; // used by BookmarkDataGroup
private var bookmarkSO2:SharedObject;
private var bookmarkSOAL2:ArrayList; // stored in bookmarkSO
private var selectedindex:int = 0;
private function init():void
{
if (configXML)
{
//labels
bookmarksLabel = configXML.labels.bookmarkslabel || "Bookmarks";
//query information
featureURL = configXML.queryinfo.featureURL;
queryAttribute = configXML.queryinfo.attribute;
featureURL2 = configXML.queryinfo2.featureURL;
queryAttribute2 = configXML.queryinfo2.attribute;
}
bookmarkAL = new ArrayList();
try
{
bookmarkSO = SharedObject.getLocal(BOOKMARKS);
}
catch (err:Error)
{
trace(err);
}
loadBookmarks();
bookmarkAL2 = new ArrayList();
try
{
bookmarkSO2 = SharedObject.getLocal(BOOKMARKS2);
}
catch (err:Error)
{
trace(err);
}
loadBookmarks2();
}
private function loadBookmarks():void
{
if (configXML)
{
var bookmarkList:XMLList = configXML..bookmark;
for (var i:int = 0; i < bookmarkList.length(); i++)
{
var name:String = bookmarkList.@name;
var icon:String = bookmarkList.@icon;
var bookmark:Object = new Object();
bookmark.name = name;
bookmark.icon = icon;
bookmarkAL.addItem(bookmark);
}
}
if (bookmarkSO)
{
bookmarkSOAL = bookmarkSO.data[BOOKMARKS] as ArrayList;
if (!bookmarkSOAL)
{
bookmarkSOAL = new ArrayList();
bookmarkSO.data[BOOKMARKS] = bookmarkSOAL;
}
else
{
bookmarkAL.addAll(bookmarkSOAL);
}
}
}
private function showBookmark(event:Event):void
{
//var bookmark:Bookmark = ItemRenderer(event.target).data as Bookmark;
query.where = queryAttribute + "='" + dropDownList1.selectedItem.name + "'";
queryTask.execute(query, new AsyncResponder(onResult, onFault));
function onResult(featureSet:FeatureSet, token:Object = null):void
{
if (featureSet.features.length == 0)
{
Alert.show("Not found.");
}
else
{
map.extent = GraphicUtil.getGraphicsExtent(featureSet.features) ;
}
}
function onFault(info:Object, token:Object = null):void
{
Alert.show(info.toString());
}
}
private function loadBookmarks2():void
{
if (configXML)
{
var bookmarkList:XMLList = configXML..bookmark2;
for (var i:int = 0; i < bookmarkList.length(); i++)
{
var name:String = bookmarkList.@name;
var icon:String = bookmarkList.@icon;
var bookmark2:Object = new Object();
bookmark2.name = name;
bookmark2.icon = icon;
bookmarkAL2.addItem(bookmark2);
}
}
if (bookmarkSO2)
{
bookmarkSOAL2 = bookmarkSO2.data[BOOKMARKS] as ArrayList;
if (!bookmarkSOAL2)
{
bookmarkSOAL2 = new ArrayList();
bookmarkSO2.data[BOOKMARKS] = bookmarkSOAL;
}
else
{
bookmarkAL2.addAll(bookmarkSOAL2);
}
}
}
private function showBookmark2(event:Event):void
{
query.where = queryAttribute + "='" + dropDownList2.selectedItem.name + "'";
queryTask.execute(query, new AsyncResponder(onResult, onFault));
function onResult(featureSet:FeatureSet, token:Object = null):void
{
if (featureSet.features.length == 0)
{
Alert.show("Not found.");
}
else
{
map.extent = GraphicUtil.getGraphicsExtent(featureSet.features) ;
}
}
function onFault(info:Object, token:Object = null):void
{
Alert.show(info.toString());
}
}
]]>
</fx:Script>
<fx:Declarations>
<esri:QueryTask id="queryTask"
url="{featureURL}"
useAMF="false"/>
<esri:Query id="query"
outSpatialReference="{map.spatialReference}"
returnGeometry="true"/>
</fx:Declarations>
<viewer:WidgetTemplate id="helloWorld"
width="300" height="300">
<viewer:layout>
<s:VerticalLayout horizontalAlign="center" verticalAlign="middle"/>
</viewer:layout>
<s:Label text="Choose a county from the droplist" />
<s:DropDownList id="dropDownList1"
labelField="name"
change="showBookmark(event)"
dataProvider="{bookmarkAL}"/>
<s:Label text="Choose a quad from the droplist" />
<s:DropDownList id="dropDownList2"
labelField="name"
change="showBookmark2(event)"
dataProvider="{bookmarkAL2}"/>
<s:Label id="lbl"
fontSize="21"
fontStyle="italic"
fontWeight="bold"/>
</viewer:WidgetTemplate>
</viewer:BaseWidget>
XML File<?xml version="1.0" ?>
<configuration>
<queryinfo>
<!-- URL of map service feature layer to query -->
<featureURL>http://labinsw2010.freac.fsu.edu/ArcGIS/rest/services/swfwmd/control2/MapServer/10</featureURL>
<!-- name of attribute in map service layer to query -->
<attribute>ctyname</attribute>
</queryinfo>
<!-- bookmark names are checked against the specified attribute -->
<bookmarks>
<bookmark name="Alachua"></bookmark>
<bookmark name="Baker"></bookmark>
<bookmark name="Bay"></bookmark>
<bookmark name="Leon"></bookmark>
</bookmarks>
<queryinfo2>
<!-- URL of map service feature layer to query -->
<featureURL>http://labinsw2010.freac.fsu.edu/ArcGIS/rest/services/swfwmd/control2/MapServer/12</featureURL>
<!-- name of attribute in map service layer to query -->
<attribute>quad</attribute>
</queryinfo2>
<!-- bookmark names are checked against the specified attribute -->
<bookmarks2>
<bookmark2 name="Leon"></bookmark2>
<bookmark2 name="Orange"></bookmark2>
</bookmarks2>
</configuration>