# How to stretch Movie Clip according to user's touch coordinates?

I have code like this:

touchX = e.stageX;
touchY = e.stageY;


I also have a player movieclip that I'm trying to make shoot lasers. So I got the MovieClip to appear and rotate according to the player's location and the user's touchX and touchY. How do I make the laser MovieClip stretch according to the distance between the player's coordinates and the touchX and touchY coordinates?

Simply have the pivot point in the center of your laser clip. Calculate the distance between the player and the input.

var dx:Number = touchX - player.x; //Assuming SAME coordinate space
var dy:Number = touchY - player.y; // Else use localToGlobal
var halfdist:Number = Math.sqrt(dx*dx+dy*dy)/2;


Now scale your movieclip by distance.

   laser.width = halfdist;


var rot:Number = Math.atan2(dy,dx);
laser.rotation = rot * (180*Math.PI);


 laser.x = Math.cos(rot) * halfdist + player.x;