Code in frame 1 layer 1


btnCalc.onRelease = function(){

  //calculate angle and length from dx and dy

  //use atan to get angle, pythagoras to get length



  radians = Math.atan(dy/dx);

  

  //convert to degrees

  degrees = radians * 180 / Math.PI;

  //offset the angle

  degrees += 90;



  //handle negative dx angles

  if (dx <0) {

    degrees -=180;

  } // end if

  

  angle = degrees;



  //use pythagorean theorom to calculate length

  length = Math.sqrt(dx*dx + dy*dy);



} // end btnCalc