Hi Robert - I am trying to modify your widget slightly by passing in the url as a variable from another widget I've created. The reason I'm doing this is that the user will only ever be able to view one layer (out of more than 100). I don't want them to have to scroll through a long list and I also don't want to have to list all of the layers in the xml file. Since all the layers have similar fields, it should work to make the url a variable and specify the remainder of the parameters in the searchwidget.xml file. To do this, I've tried to create a global variable class which looks like this:package com.esri.viewer.utils
{
public class GlobalVarContainer
{
public static var vars:Object = {};
public static var searchurl:String = "" ;
}
}
Then in my widgetimport com.esri.viewer.utils.GlobalVarContainer;
//and within my function that specifies which map service and layer to display I try to pass the url //to the global variable searchurl
for each (var item : LayerInfo in alllayers)
{
var lyrname:String = item.name;
if (lyrname == qryname)
{
var lyrnum:String = item.id.toString();
var urlstr:String = lyr.url + "/" + lyrnum;
GlobalVarContainer.searchurl = urlstr;
visibleLayers.addItem(item.id); // add id
}
Then in SearchWidget.mxmlimport com.esri.viewer.utils.GlobalVarContainer;
//and within private function init():void
for (var i:Number = 0; i < lyrList.length(); i++)
{
//var lyrURL:String = lyrList.url;
var lyrURL:String = GlobalVarContainer.searchurl;
When I debug, I get the error in my widget "No such variable: GlobalVarContainer"Any suggestions? I've read that trying to create global variables is frowned upon but I'm not sure how else to approach it.Any help would be greatly appreciated!!Thanks!Barb Patterson