5 Replies Latest reply on Apr 14, 2011 7:14 AM by gspirido

    Could not resolve "" to a component implement & other things.

    MyersJ22

      Hello again! I was able to solve my last problems, thanks to some advice from here, so I am wondering if anyone can teach me how I can avoid the error below and how to fix it. I keep finding this error a lot and sometimes I am able to fix it but sometimes I am not able to. When I do fix it, I am not always sure on how it got fixed as usually I just move things around. I am new with Flex but please be patient.

      Could not resolve <esri:Draw> to a component implementation.

      Below is my full source code. Everything that is in bold is where the error is currently. Please try to remember that I am wanting to know how to avoid these errors and know how to fix them.

      <?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"
                     pageTitle="Austin Peay State University"
                     initialize="initApp()">

          <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 com.esri.ags.tasks.RouteTask;
                  import com.esri.ags.events.DrawEvent;
                  import com.esri.ags.events.GeoprocessorEvent;
                  import com.esri.ags.tasks.FeatureSet;
                  import com.esri.ags.tasks.ParameterValue;
                 
                  import mx.events.FlexEvent;               
                  import mx.logging.LogEventLevel;
                  import mx.collections.ArrayCollection;
                  import mx.controls.Alert;
                  import mx.rpc.events.FaultEvent;
                  import mx.printing.FlexPrintJobScaleType;
                  import mx.printing.FlexPrintJob;
                  import mx.controls.Button;   
                 
                  import spark.components.Label;           
                  import spark.events.IndexChangeEvent;
                 
                  [Bindable]private var stops:FeatureSet = new FeatureSet([]);
                  [Bindable]private var barriers:FeatureSet = new FeatureSet([]);           
                  [Bindable]private var selectedBtn:mx.controls.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());
                      }
                  }
                  private function doPrint(myFlexPrintJobScaleType:String):void
                  {
                      // Create an instance of the FlexPrintJob class.
                      var myPrintJob:FlexPrintJob = new FlexPrintJob();
                     
                      // Start the print job.
                      if (myPrintJob.start())
                      {
                          try
                          {
                              // hide the zoom slider so it won't be printed
                              myMap.zoomSliderVisible = false;
                             
                              // Add the panel to print.
                              myPrintJob.addObject(mapPanel, myFlexPrintJobScaleType);
                             
                              // turn the zoom slider back on
                              myMap.zoomSliderVisible = true;
                          }
                          catch (error:Error)
                          {
                              Alert.show(error.toString());
                          }
                          // Send the job to the printer.
                          myPrintJob.send();
                      }
                  }
                 
                  private function drawStartHandler(event:DrawEvent):void
                  {
                      graphicsLayer.clear();
                      surfaceProfilePanel.visible = false;
                  }
                 
                  private function drawEndHandler(event:DrawEvent):void
                  {
                      var featureSet:FeatureSet = new FeatureSet([event.graphic]);
                      var params:Object = {
                          "Input_Polylines": featureSet,
                          "Image_Width": 600,
                          "Image_Height": 250,
                          "Display_Segments": true
                      };
                      gp.execute(params);
                  }
                 
                  private function gpExecuteCompleteHandler(event:GeoprocessorEvent):void
                  {
                      var paramValue:ParameterValue = event.executeResult.parameterValues[0];
                      var featureSet:FeatureSet = FeatureSet(paramValue.value);
                      var profileURL:String = featureSet.attributes[0].profileURL;
                      surfaceProfileImage.source = profileURL;
                  }           
              ]]>
          </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/Campus_Bldgs/MapServer/find"/>
             
              <esri:FindParameters id="myFindParams"
                                   contains="true"
                                   layerIds="[0]"
                                   outSpatialReference="{myMap.spatialReference}"
                                   returnGeometry="true"
                                   searchFields="[BUILDING_N,BUILDINGID]"
                                   searchText="{fText.text}"/>
             
              <esri:RouteTask id="routeTask"
                              concurrency="last"
                              fault="faultHandler(event)"
                              requestTimeout="30"
                              showBusyCursor="true"
                              solveComplete="solveCompleteHandler(event)"
                              url="http://peaymapper.apsu.edu/arcgis/rest/services/APSU/walkingwgs84/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: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:Button click="doPrint(FlexPrintJobScaleType.NONE)" label="Print (without scaling)" y="80"/>
                              <s:Button click="doPrint(FlexPrintJobScaleType.SHOW_ALL)" label="Print (fit on one page)" y="60"/>                           
                          </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%">
                  <s:Panel id="mapPanel" title="Austin Peay State University" width="100%" height="100%">
                      <s:Label id="resultSummary" height="15"/>
                      <esri:Geoprocessor id="gp"
                                         url="http://sampleserver2.arcgisonline.com/ArcGIS/rest/services/Elevation/ESRI_Elevation_World/ GPServer/ProfileService"
                                         executeComplete="gpExecuteCompleteHandler(event)"
                                         fault="Alert.show(event.fault.message)"/>
                      <esri:Draw id="drawToolbar" map="{myMap}" graphicsLayer="{graphicsLayer}" drawStart="drawStartHandler(event)" drawEnd="drawEndHandler(event)">
                          <esri:lineSymbol>
                              <esri:SimpleLineSymbol color="0x0000FF" width="4"/>
                          </esri:lineSymbol>
                      </esri:Draw>
                    
                      <esri:Map id="myMap"
                          extent="{initialExtent}"
                          level="16" height="100%" width="100%"
                          mapClick="mapClickHandler(event)"
                          openHandCursorVisible="false"
                          load="drawToolbar.activate(Draw.POLYLINE)">
                          <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:GraphicsLayer id="graphicsLayer"/>                   
                      </esri:Map>               
                  </s:Panel>
              </mx:VDividedBox>
          </mx:HDividedBox>

          <mx:Panel id="surfaceProfilePanel" title="Surface Profile" top="10" right="10" visible="false">
              <mx:Image id="surfaceProfileImage" complete="surfaceProfilePanel.visible = true"/>
          </mx:Panel>   
      </s:Application>

      Now, there are a few other things I would like to do but have no idea how to do. Flex is completely different from C++ in my opinion. So we'll get to those after this problem is done.