Tony,
Look at this sample.
http://help.arcgis.com/en/webapi/flex/samples/index.html?sample=MeasureDistance
distance(distanceParameters:DistanceParameters, responder:IResponder = null):AsyncToken
The distance operation is performed on a geometry service resource (only available with ArcGIS Server 10.0 or above).
Tony,
What does your code for building the polyline look like?