Thread: Coordinate Help
View Single Post
03-25-2007, 01:38 PM
#2
Wildhoney is offline Wildhoney
Wildhoney's Avatar
Status: Request a custom title
Join date: Feb 2006
Location: Nottingham
Expertise:
Software:
 
Posts: 1,648
iTrader: 18 / 95%
 

Wildhoney is on a distinguished road

Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney

  Old

I do not know of a function to do this, but I've just worked out the algorithm for you, of which I believe will work. Bearing in mind that you want the coordinates of the top left point of the image. You would have the following algorithm:

Code:
X - Y = Z / 2 = Axis Position
For instance, if the width of my document was 800 pixels and the height 400 pixels. The image I am loading in is 450 pixels by 200 pixels. The following algorithm would be used:

Code:
Width:	800 - 450 = 350 / 2 = 125 = X
Height:	400 - 200 = 200 / 2 = 100 = Y
That is:

Code:
Document Width - Image Width = 350 / 2 = 125 (Which is X)
Therefore you would set ._x and ._y to 125 and 100, respectively. I have also wrote you a function for this to be used in Actionscript:

Code:
function getCentreAxis(iWidth, iHeight)
{
	arXY = new Array();
	arXY.push((Stage.width - iWidth) / 2);
	arXY.push((Stage.width - iHeight) / 2);
	return arXY;
}