# Dynamic coordinates for copyPixels rectangle

**URL:** <https://forum.kirupa.com/t/dynamic-coordinates-for-copypixels-rectangle/309092>\
**Category:** flash\
**Created:** [May 6, 2010, 3:55pm UTC](https://forum.kirupa.com/t/dynamic-coordinates-for-copypixels-rectangle/309092 "2010-05-06T15:55:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tcambron](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@tcambron](https://forum.kirupa.com/u/tcambron)\
**Post date:** [May 6, 2010, 3:55pm UTC](https://forum.kirupa.com/t/dynamic-coordinates-for-copypixels-rectangle/309092/1 "2010-05-06T15:55:59Z")

</div>

Greetings,

I believe this is esentially a math problem that may be easy for most of the programmers out there, but I am stuck. I have a fixed rectangle width = 50 height = 50 centered in the middle of the stage. I am using this rectangle to copyPixels of a bitmap that is also centered on the stage. The bitmap is draggable. I can define the initial x,y of the rectangle used for copyPixels with

function mouseUpHandler(e:MouseEvent):void  
{  
…  
// initial x,y of centered retangle  
cropAreaX = (loaderUI.width/2) - 25;  
cropAreaY = (loaderUI.height/2) - 25;

imageBMPData.copyPixels(imageBMP, new Rectangle(cropAreaX,cropAreaY,50,50), new Point(0,0));  
…  
}

Once the bitmap is dragged in relationship to the fixed rectangle I do not know how to calculate the new x,y(cropAreaX and cropAreaY).

Any help would be greatly appreciated.
