Embrace the timeline….

On creating rich, flashy and immersive advertising experiences online by Owen van Dijk

The mystery of the shifting pixel.

leave a comment »

If you spent too much time working in the Flash IDE, you might have wondered why Flash sometimes shifts coordinates of objects. For example after transforming graphics or bitmaps, the x value of 200 shifts to 200.1. I usually correct this by hand ( hmm..i wonder if JSFL could help me with this? ) but wondered why this annoying behavior happened in the first place.

Recently, Gary Grossman, came with the following explanation:

Coordinates in Flash are fixed point numbers. A 32-bit integer is divided
into an integer half and a fractional half.


The “.” is the “binary point”, like a decimal point.

For instance, the number 200.5 would be represented as

0000000011001000 . 1000000000000000

This representation was chosen for speed back in the FutureSplash days.
Back then, Flash was running on machines like 486/33’s. Fixed point numbers
was the only way to reasonably render Bezier curves in real-time… the
FPU’s on older PC’s were just not powerful enough to do all of these
calculations with floating point numbers.

This representation has its limits. The smallest fraction that can be
represented is 1/(2**16) or 1/65536, which is 0.000015. Anything after that
will just be rounded off.

0.000015 sounds pretty small, but whenever you do a transformation like a
scale or rotate, or group something or turn it into a symbol, that is
expressed as a 2D matrix multiply which is a series of math operations.
Each operation adds its own contribution to the final round-off error. What
you’re seeing when a coordinate goes from 200 to 200.1, etc. is when the
round-off error was bigger than 0.05 and enough to knock it over to the next
tenth in the decimal representation.

In this day and age, floating point support is much better on PC’s (games
rely on it heavily) and Macromedia could conceivably rewrite the low-level
geometry and shape engines in Flash and the Flash Player to use floating
point instead of fixed-point representations. Round-off error still happens
in floating point, but the precision of math operations would be much higher
so it’d be a lot harder to get it to manifest.


It would take several hotshot graphics engineers many months to do it,
and it would have to be a coordinated effort for both the Flash Authoring Tool
and Flash Player. There would be mammoth considerations for compatibility
with existing FLA and SWF files to not break anything. A lot of up-front design
work would have to happen, followed by a long and hard implementation
and testing phase.

Non-geek translation: If we want Macromedia to solve this, we should let them know through the Flash Feedback Form. 🙂


Written by ohwhen

May 13, 2004 at 6:02 pm

Posted in Web/Tech

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: