m90
February 9th, 2009, 05:57 AM
Hello!
I have a MC on stage that I dynamically add and remove elements to and from. Since its dimensions vary subject to those changes I's like to "pin-point" it to the center of my (800x600) stage. I thought it would be agood idea to get the dimensions of the MC (it's called container) and set its x and y accordingly, but somehow it won't work as I got the feeling the registration is somewhere else (and I don't get the logic behind where it is).
The code I am using at the moment is the following
var dimensions:Rectangle = container.getBounds(stage);
container.x = 400 - dimensions.width/2;
container.y = 300 - dimensions.height/2;
Thanks alot in advance!
I have a MC on stage that I dynamically add and remove elements to and from. Since its dimensions vary subject to those changes I's like to "pin-point" it to the center of my (800x600) stage. I thought it would be agood idea to get the dimensions of the MC (it's called container) and set its x and y accordingly, but somehow it won't work as I got the feeling the registration is somewhere else (and I don't get the logic behind where it is).
The code I am using at the moment is the following
var dimensions:Rectangle = container.getBounds(stage);
container.x = 400 - dimensions.width/2;
container.y = 300 - dimensions.height/2;
Thanks alot in advance!