I was a bit of a twit until I discovered twips.

When positioning display objects in Actionscript we use the x and y properties.

These related to pixels. But what if you need half a pixel or 0.12345 of a pixel.

Flash does allow you to position object using ‘twips’. A twip is 1/20 of a pixel or 0.05. This allows you to position display objects in multiples of 0.05.

In my project I wanted to increment the x value by 0.11799410029498525. This caused a problem as the object didn’t move as far as it should as it kept getting rounded down.

I created a varable called ‘stepLength’ holding my decimal. A second variable called ‘newPos ‘ was incremented with ‘stepLength’. This was then used to set the position of my displayobject.

newPos += stepLength;
myDisplayObject.x = newPos ;

As such the x value is only rounded to a twip when set and not when incremented so the object moved as desired.

Leave a Comment