I had to do something like this the other day, Ill post if anyone still needs it:
var startPoint:MapPoint = new MapPoint(geom.x, geom.y);
var endPoint:MapPoint = new MapPoint(endX,endY);
//Create polyline between these points
var newPath:Array = [];
newPath.push(startPoint,endPoint);
var polyline:Polyline = new Polyline([newPath], geom.spatialReference);