Dynamic Positioning

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Pezmc
Forum Commoner
Posts: 53
Joined: Mon Nov 06, 2006 2:15 pm

Dynamic Positioning

Post 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!
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: Dynamic Positioning

Post by kaszu »

I guess you should round the position
Post Reply