Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have published a network analyst service and I'm trying to use it from the Flex API 3.1. When I use the service in ArcMap or through the rest GUI in a browser, the service returns the right answer. When I use the service from the Flex API 3.1, my object "routeResult" that contains the route returned by the server is null. I get the error: "Error #1009: Cannot access a property or method of a null object reference." for the object routeResult. Here is my application code:


        import com.esri.ags.FeatureSet;
        import com.esri.ags.Graphic;
        import com.esri.ags.symbols.CompositeSymbol;
        import com.esri.ags.symbols.SimpleMarkerSymbol;
        import com.esri.ags.symbols.TextSymbol;
        import com.esri.ags.tasks.supportClasses.RouteResult;

        import mx.controls.Alert;

        [Bindable]private var stops:FeatureSet = new FeatureSet([]);

        [Bindable]private var lastRoute:Graphic;            

        private function mapClickHandler(event:MapMouseEvent):void
            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);

            if (stops.features.length > 1)

        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
   + "\n\n" + event.fault.faultDetail, "Routing Error " + event.fault.faultCode);
            // Supprimer le dernier stop ou les deux s'il n'y en a pas plus.
            if (stops.features.length <= 2)
                stops = new FeatureSet([]);


    <esri:MapPoint id="mapPoint" x="655672" y="6861079"/>

    <esri:RouteTask id="routeTask" concurrency="last" fault="faultHandler(event)"
                    requestTimeout="30" showBusyCursor="true"

    <esri:RouteParameters id="routeParams" stops="{stops}" returnDirections="false"/>

    <esri:SimpleLineSymbol id="routeSymbol" width="5" alpha="0.6" color="0x000099"/>

<s:BorderContainer id="applicationHolder" width="100%" height="100%">


    <s:SkinnableContainer id="headerBar" width="100%" height="50" backgroundColor="0xcccccc">
            <s:HorizontalLayout verticalAlign="middle"/>

        <mx:Text id="titleText" fontSize="25" fontWeight="bold"
                 text="My application"/>
        <mx:Spacer width="75"/>         


    <esri:Map id="mainMap" width="100%" height="100%" center="{mapPoint}"
              crosshairVisible="{crosshairsCheck.selected}" level="16"
              mapClick="mapClickHandler(event)" panArrowsVisible="{panArrowsCheck.selected}">
        <esri:ArcGISDynamicMapServiceLayer url="http://serverIP:8399/arcgis/rest/services/myMapService/MapServer"/>

        <esri:GraphicsLayer graphicProvider="{lastRoute}" symbol="{routeSymbol}"/>
        <esri:GraphicsLayer id="inputsLayer"/>


Do you have any advice?


share|improve this question
Have you used firebug or fiddler to make sure all the parameters being passed in are correct? – Jamie Dec 27 '12 at 16:16
@Jamie In FireBug parameters are : f json returnBarriers false returnDirections false returnPolygonBarriers false returnPolylineBarriers false returnRoutes true returnStops false stops {"features":[{"geometry":{"x":655563.9391567005,"spatialReference":{"wkid"‌​:2154},"y":6861469.492592832}},{"geometry":{"x":655344.5428990924,"spatialReferen‌​ce":{"wkid":2154},"y":6861367.980891551}}],"doNotLocateOnRestrictedElements":fals‌​e,"type":"features"} So I suppose yes. The parameters sent to the server are correct. – yo_haha Dec 27 '12 at 16:46
up vote 1 down vote accepted

Solved. In the object Routetask:

<esri:RouteTask id="routeTask" concurrency="last" fault="faultHandler(event)"
                    requestTimeout="30" showBusyCursor="true"

In the url attribute, there is a mistake. Instead of /MapServer there should be /NAServer like this:

share|improve this answer
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. – R.K. Dec 28 '12 at 14:50
Ok thanks for the comment. I'm the author of the question and I have answered it. I have provided a more detailed answer. I agree with you, the previous answer wasn't clear. – yo_haha Dec 28 '12 at 15:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.