Page 1 of 1

Dynamic Positioning

Posted: Mon Jul 14, 2008 2:01 am
by Pezmc
I am using actionscript to place every thing on the flash dynamically. However, when I was finished I noticed a tiny little bug that I just can't fix. Whenever the stage.height is an even number one of the objects is misaligned by half a pixel. When ever the stage.height is odd it is perfect. See images below for what I mean.

Here is the related actionscript (called upon load and resize):
[AS]
left_object1._x = Stage.width / 2 - left_object1._width;
left_object1._y = Stage.height / 2 - (left_object1._height / 2);
right_object2._width = Stage.width / 2;
right_object2._x = Stage.width / 2;
right_object2._y = Stage.height / 2 - (right_object2._height / 2);
[/AS]

Object 1 is: 109px x 255px
Object 2 is: 1/2 stage width x 253px

Image
Image
Image

Does anyone know how to fix this silly problem? I was thinking something to do with rounding down? But I don't know really. I would really appreciate the help!

Re: Dynamic Positioning

Posted: Mon Jul 14, 2008 12:04 pm
by kaszu
I guess you should round the position