4 Replies Latest reply on Oct 22, 2010 11:48 AM by MyersJ22

    Help: Can not resolve a multiname reference unambiguously.

    MyersJ22 Level 1

      I get the following error in my code:

      Can not resolve a multiname reference unambiguously. mx.controls:Button (from C:\Program Files\Adobe\Adobe Flash Builder 4\sdks\4.1.0\frameworks\libs\framework.swc(mx.controls:Button)) and spark.components:Button (from C:\Program Files\Adobe\Adobe Flash Builder 4\sdks\4.1.0\frameworks\libs\spark.swc(spark.components:Button)) are available.    Resource: ArcGIS.mxml    Path: /ArcGIS/src    Location: Unknown    Type: Flex Problem

      I am new to Flex and am slowly learning how to program it. I, however, seem to get along with Murphy as I always have one more bug. This just came up in my code when I added a routing with barriers function to application. I have narrowed it down to where I believe the problem is but I do not know how to fix it. Where I have narrowed it down to is in bold.

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:s="library://ns.adobe.com/flex/spark"
                     xmlns:esri="http://www.esri.com/2008/ags"
                     xmlns:mx="library://ns.adobe.com/flex/mx"
                     initialize="initApp()"              
                     pageTitle="Austin Peay State University">

          <s:layout>
              <s:VerticalLayout paddingBottom="10"
                                paddingLeft="10"
                                paddingRight="10"
                                paddingTop="10"/>
          </s:layout>   
         
          <fx:Script>
              <![CDATA[
                  import com.esri.ags.Graphic;
                  import com.esri.ags.events.FindEvent;
                  import com.esri.ags.geometry.Extent;
                  import com.esri.ags.tasks.supportClasses.FindResult;
                  import com.esri.ags.utils.GraphicUtil;           
                  import com.esri.ags.geometry.MapPoint;
                  import com.esri.ags.layers.TiledMapServiceLayer;
                  import com.esri.ags.tools.NavigationTool;
                  import com.esri.ags.FeatureSet;
                  import com.esri.ags.events.MapMouseEvent;
                  import com.esri.ags.events.RouteEvent;
                  import com.esri.ags.symbols.CompositeSymbol;
                  import com.esri.ags.symbols.TextSymbol;
                  import com.esri.ags.tasks.supportClasses.RouteResult;
                 
                  import mx.events.FlexEvent;               
                  import mx.logging.LogEventLevel;
                  import mx.collections.ArrayCollection;
                  import mx.controls.Alert;
                  import mx.rpc.events.FaultEvent;
                 
                  import spark.events.IndexChangeEvent;
                 
                  [Bindable]private var stops:FeatureSet = new FeatureSet([]);
                  [Bindable]private var barriers:FeatureSet = new FeatureSet([]);           
                  [Bindable]private var selectedBtn:Button;           
                  [Bindable]private var lastRoute:Graphic;
                             
                  private function layerShowHandler(event:FlexEvent):void
                  {
                      var tiledLayer:TiledMapServiceLayer = event.target as TiledMapServiceLayer;
                      myMap.lods = tiledLayer.tileInfo.lods;
                  }
                 
                  private function tbb_changeHandler(event:IndexChangeEvent):void
                  {
                      switch (tbb.selectedItem)
                      {
                          case "Zoom In":
                          {
                              navTool.activate(NavigationTool.ZOOM_IN);
                              break;
                          }
                          case "Zoom Out":
                          {
                              navTool.activate(NavigationTool.ZOOM_OUT);
                              break;
                          }
                          case "Pan":
                          {
                              navTool.activate(NavigationTool.PAN);
                              break;
                          }
                          default:
                          {
                              navTool.deactivate();
                              break;
                          }
                      }
                  }
                 
                  private function doFind():void
                  {
                      findTask.execute(myFindParams);
                  }
                 
                  private function executeCompleteHandler(event:FindEvent):void
                  {
                      myGraphicsLayer.clear();
                     
      //                resultSummary.text = "Found " + event.findResults.length + " results.";
                      myGraphicsLayer.symbol = sfsFind;
                     
                      var resultCount:int = event.findResults.length;
                     
                      if (resultCount == 0)
                      {
                          Alert.show("No buildings found. Please change your search.");
                      }
                      else
                      {
                          // add feature as graphic to graphics layer
                          for (var i:int = 0; i < resultCount; i++)
                          {
                              var graphic:Graphic = FindResult(event.findResults[i]).feature;
                              graphic.toolTip = event.findResults[i].foundFieldName + ": " + event.findResults[i].value;
                              myGraphicsLayer.add(graphic);
                          }
                         
                          // zoom to extent of all features
                          var graphicProvider:ArrayCollection = myGraphicsLayer.graphicProvider as ArrayCollection;
                          var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(graphicProvider.toArray());
                          myMap.extent = graphicsExtent.expand(3.1); // zoom out a little
                      }
                  }
                 
                  private function initApp():void
                  {
                      selectedBtn = addStopsBtn;
                  }
                 
                  private function mapClickHandler(event:MapMouseEvent):void
                  {
                      if (selectedBtn == addStopsBtn)
                      {
                          var stopSymbol:CompositeSymbol = new CompositeSymbol();
                          var circleSym:SimpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 20, 0x000099);
                          var textSym:TextSymbol = new TextSymbol(String(stops.features.length + 1));
                          textSym.textFormat = new TextFormat("Verdana", null, null, true);
                          textSym.color = 0xFFFFFF;
                          stopSymbol.symbols = [ circleSym, textSym ];
                          var stop:Graphic = new Graphic(event.mapPoint, stopSymbol);
                          inputsLayer.add(stop);
                          stops.features.push(stop);
                      }
                      else
                      {
                          var barrier:Graphic = new Graphic(event.mapPoint, barrierSymbol);
                          inputsLayer.add(barrier);
                          barriers.features.push(barrier);
                      }
                     
                      if (stops.features.length > 1)
                      {
                          routeTask.solve(routeParams);
                      }
                  }
                 
                  private function solveCompleteHandler(event:RouteEvent):void
                  {
                      var routeResult:RouteResult = event.routeSolveResult.routeResults[0];
                      lastRoute = routeResult.route;
                      lastRoute.toolTip = routeResult.routeName;
                      if (routeResult.route.attributes.Total_Time)
                      {
                          lastRoute.toolTip += " in " + Math.round(Number(routeResult.route.attributes.Total_Time)) + " minutes.";
                      }
                  }
                 
                  private function faultHandler(event:FaultEvent):void
                  {
                      Alert.show(event.fault.faultString + "\n\n" + event.fault.faultDetail, "Routing Error " + event.fault.faultCode);
                      // remove last stop (or both stops if only two)
                      if (stops.features.length <= 2)
                      {
                          inputsLayer.clear();
                          stops = new FeatureSet([]);
                      }
                      else
                      {
                          inputsLayer.remove(stops.features.pop());
                      }
                  }           

              ]]>
          </fx:Script>
         
          <fx:Declarations>   
              <esri:Extent id="initialExtent" xmin="-9724772" ymin="4374071" xmax="-9723613" ymax="4374822">
                  <esri:SpatialReference wkid="102100"/>
              </esri:Extent>
              <esri:NavigationTool id="navTool" map="{myMap}"/>
             
              <mx:TraceTarget includeCategory="true"
                              includeLevel="true"
                              includeTime="true"
                              level="{LogEventLevel.DEBUG}"/>
             
              <!-- Symbol for Find Result as Polygon -->
              <esri:SimpleFillSymbol id="sfsFind" alpha="0.7"/>
             
              <!-- Find Task -->
              <esri:FindTask id="findTask"
                             executeComplete="executeCompleteHandler(event)"
                             url="http://peaymapper.apsu.edu/arcgis/rest/services/APSU"/>
             
              <esri:FindParameters id="myFindParams"
                                   contains="true"
                                   layerIds="[2]"
                                   outSpatialReference="{myMap.spatialReference}"
                                   returnGeometry="true"
                                   searchFields="[BUILDING_N]"
                                   searchText="{fText.text}"/>
              <esri:RouteTask id="routeTask"
                              concurrency="last"
                              fault="faultHandler(event)"
                              requestTimeout="30"
                              showBusyCursor="true"
                              solveComplete="solveCompleteHandler(event)"
                              url="http://tasks.arcgisonline.com/ArcGIS/rest/services/NetworkAnalysis/ESRI_Route_NA/NAServer/Route"/>
             
              <esri:RouteParameters id="routeParams"
                                    outSpatialReference="{myMap.spatialReference}"
                                    pointBarriers="{barriers}"
                                    stops="{stops}"/>
             
              <esri:SimpleMarkerSymbol id="barrierSymbol2"
                                       color="0xFF0000"
                                       size="15"
                                       style="x">
                  <esri:SimpleLineSymbol width="4"/>
              </esri:SimpleMarkerSymbol>
             
              <esri:PictureMarkerSymbol id="barrierSymbol" source="http://help.arcgis.com/en/webapi/flex/samples/assets/road-closed-32x32.png"/>
             
              <esri:SimpleLineSymbol id="routeSymbol"
                                     width="5"
                                     alpha="0.6"
                                     color="0x000099"/>       

          </fx:Declarations>
         
          <mx:Panel title="Austin Peay State University" width="100%" height="100%">
              <mx:HDividedBox width="100%" height="100%">
                  <mx:TabNavigator width="30%" height="100%">
                      <s:NavigatorContent label="Controls" width="100%" height="100%">
                          <mx:Accordion x="0" y="0" width="100%" height="100%">
                              <s:NavigatorContent label="Navigation" width="100%" height="100%">
                                  <s:ButtonBar id="tbb" change="tbb_changeHandler(event)" x="0" y="20">
                                      <s:ArrayList>
                                          <fx:String>Zoom In</fx:String>
                                          <fx:String>Zoom Out</fx:String>
                                          <fx:String>Pan</fx:String>
                                      </s:ArrayList>
                                  </s:ButtonBar>
                                  <s:Button click="navTool.zoomToFullExtent()" label="Full Extent" x="183" y="40"/>   
                                  <s:ButtonBar id="bb"
                                               requireSelection="true" x="0" y="0">
                                      <s:dataProvider>
                                          <s:ArrayList>
                                              <fx:String>Service</fx:String>
                                              <fx:String>Streets</fx:String>
                                              <fx:String>U.S. Topo</fx:String>
                                              <fx:String>Imagery</fx:String>
                                          </s:ArrayList>
                                      </s:dataProvider>
                                  </s:ButtonBar>                           
                                  <s:Button click="navTool.zoomToPrevExtent()"
                                            enabled="{!navTool.isFirstExtent}"
                                            label="Previous Extent" x="0" y="40"/>
                                  <s:Button click="navTool.zoomToNextExtent()"
                                            enabled="{!navTool.isLastExtent}"
                                            label="Next Extent" x="104" y="40"/>
                              </s:NavigatorContent>
                              <s:NavigatorContent label="Routing" width="100%" height="100%">
                                  <mx:Button id="addStopsBtn"
                                             click="selectedBtn = addStopsBtn"
                                             label="Add Stops"
                                             selected="{selectedBtn == addStopsBtn}" x="0" y="0"/>
                                  <mx:Button id="addBarriersBtn"
                                             click="selectedBtn = addBarriersBtn"
                                             label="Add Barriers"
                                             selected="{selectedBtn == addBarriersBtn}" x="0" y="20"/>
                                  <mx:Button label="Clear" x="0" y="40">
                                      <mx:click>
                                          <![CDATA[
                                          stops = new FeatureSet([]);
                                          barriers = new FeatureSet([]);
                                          lastRoute = new Graphic;
                                          inputsLayer.clear();
                                          ]]>
                                      </mx:click>
                                  </mx:Button>

                              </s:NavigatorContent>                       
                          </mx:Accordion>   
                      </s:NavigatorContent>
                      <s:NavigatorContent label="Find" width="100%" height="100%">
                          <mx:HBox x="0" y="0">   
                              <s:TextInput id="fText"
                                  enter="doFind()"
                                  maxWidth="400"
                                  text="Enter Text..."/>
                              <s:Button click="doFind()" label="Find"/>       
                          </mx:HBox>
                          <mx:DataGrid width="100%" height="40%"
                                       dataProvider="{findTask.executeLastResult}" x="0" y="31">
                              <mx:columns>
                                  <mx:DataGridColumn width="70"
                                                     dataField="layerId"
                                                     headerText="Layer ID"/>
                                  <mx:DataGridColumn dataField="layerName" headerText="Layer Name"/>
                                  <mx:DataGridColumn dataField="foundFieldName" headerText="Field Name"/>
                                  <mx:DataGridColumn dataField="value" headerText="Field Value"/>
                              </mx:columns>
                          </mx:DataGrid>
                      </s:NavigatorContent>               
                      <s:NavigatorContent label="Legend" width="100%" height="100%">
                      </s:NavigatorContent>
                  </mx:TabNavigator>
                  <mx:VDividedBox width="100%" height="100%">
                      <esri:Map id="myMap"
                                extent="{initialExtent}"
                                level="16" height="100%" y="439" width="100%" x="585"
                                mapClick="mapClickHandler(event)"
                                openHandCursorVisible="false">
                          <esri:ArcGISDynamicMapServiceLayer show="layerShowHandler(event)"
                                                           url="http://peaymapper.apsu.edu/arcgis/rest/services/APSU/networkwalking/MapServer"
                                                           visible="{bb.selectedIndex == 0}"/>                   
                          <esri:ArcGISDynamicMapServiceLayer show="layerShowHandler(event)"
                                                           url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
                                                           visible="{bb.selectedIndex == 1}"/>
                          <esri:ArcGISDynamicMapServiceLayer show="layerShowHandler(event)"
                                                           url="http://server.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer"
                                                           visible="{bb.selectedIndex == 2}"/>
                          <esri:ArcGISDynamicMapServiceLayer show="layerShowHandler(event)"
                                                           url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"
                                                           visible="{bb.selectedIndex == 3}"/>
                          <esri:GraphicsLayer id="myGraphicsLayer"/>
                          <esri:GraphicsLayer graphicProvider="{lastRoute}" symbol="{routeSymbol}"/>
                          <esri:GraphicsLayer id="inputsLayer"/>                   
                      </esri:Map>
                  </mx:VDividedBox>
              </mx:HDividedBox>
          </mx:Panel>
      </s:Application>

      Can anyone help a newbie at flex? xD It would be good if you could help me understand the problem, how to fix the problem, and how to avoid it. I would like to fix my programming, yes, but I would also like to learn.

       

      Thank you!