Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 563 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     Flash and Actionscript :

Coordinate Help

Thread title: Coordinate Help
Closed Thread    
    Thread tools Search this thread Display Modes  
03-24-2007, 05:43 AM
#1
Xuxa is offline Xuxa
Status: Request a custom title
Join date: Feb 2006
Location: USA
Expertise:
Software:
 
Posts: 1,076
iTrader: 17 / 95%
 

Xuxa is on a distinguished road

Send a message via MSN to Xuxa

  Old  Coordinate Help

I have a .xml file which loads the images into flash and I have a empty movie clip with a pivot. I want to make it centered but it makes it 0,0 (x,y) and some pictures have different widths. How do I make it so all images are centered?

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;
}

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed