`

Wednesday, September 15, 2010

Flash 0.05 Twip “Issue”

If you ever try to add any number smaller than 0.05 to the x or y properties of any graphic, then you’ll will notice nothing will happen. It will not add anything smaller than 0.05.

Actually, this issue is due to the way Flash deals with pixels. In the wonderful world of typography, 1/20 of a pixel is called a twip, and 1/20 in decimals is not surprisingly 0.05. Graphics in Flash are positioned using twips, so Flash just ignores you if you try to move an object less than a twip.

Well, the solution is simple:

Instead of something like:

  • graphic.y += velocity.y; // velocity.y may be smaller than 0.05
you do something like:
  • yPositionTemp += velocity.y;
  • graphic.y = yPositionTemp;

No comments: