In a different post I figured out how to use the Geometry Server to project a point, see:
http://forums.arcgis.com/threads/14793-UTM-or-State-Plane-to-Decimal-Degrees
However, I'm still left with a question. My question is there anyway to avoid adding the Declarations section at the end (i.e. just define the geometryService info in the body of the ActionScript function)??
This is what I'm currently adding:
Thanks
public function convertToPoint(x:Number, y:Number, bool:Boolean):Point { var _pointObject:MapPoint = new MapPoint(); _pointObject.spatialReference = new SpatialReference(4326); _pointObject.x = x; _pointObject.y = y; if((bool) && (!isNaN(x)) && (!isNaN(y))) { //_pointObject = WebMercatorUtil.geographicToWebMercator(_pointObject) as MapPoint; var geomServ:GeometryService = new GeometryService("https://my-imap.austinisd.org/arcgis/rest/services/Utilities/Geometry/GeometryServer"); //geomServ.addEventListener(GeometryServiceEvent.PROJECT_COMPLETE,pResult); const projParams:ProjectParameters = new ProjectParameters(); projParams.geometries = [_pointObject ]; var outSR:SpatialReference = new SpatialReference(2277); projParams.outSpatialReference = outSR; geomServ.project(projParams, new AsyncResponder( function pResult(item:Object, token:Object = null):void{ var pt:MapPoint = (item as Array)[0] as MapPoint; _pointObject.x = pt.x; _pointObject.y = pt.y; }, function pFault(fault:Fault, token:Object = null):void{ Alert.show("Error: " + fault.faultString, "Error code: " + fault.faultCode); } ) ); }
https://my-imap.austinisd.org/arcgis/rest/services/Utilities/Geometry/GeometryServer/project?outSR=2277&f=json&geometries={%22geometryType%22%3A%22esriGeometryPoint%22%2C%22geometries%22%3A[{%22x%22%3A-97.75055769%2C%22y%22%3A30.22752472}]}&inSR=4326