• Keep in touch:
  • Linked In
  • Twitter
  • RSS

What are bounding boxes?

Each visible object in a Flash file has an associated frame or bounding box which defines the area on the screen occupied by the object and allows the Flash Player to determine which area needs repainted if an object changes.

bounding box extends from top left to lower right

In Flash the axes are specified relative to the top left corner of the screen and the bounding box is defined by two pairs of coordinates that identify the top left and bottom right corners of a rectangle. This is contrary to the Cartesian coordinate system and often results in objects appearing upside down when first attempting to draw shapes.

Coordinate Space

The coordinates for each corner also specify the coordinate range so specifying a bounding rectangle with the points (-100,-100) and (100,100) defines a rectangle 200 twips by 200 twips with the point (0,0) located in the centre. Specifying the points (0,0) and (200,200) defines a rectangle with the same size however the centre is now located at (100,100).

bounding box also defines the coordinate space

Like all graphics systems, the coordinate space when drawing a shape is independent of the coordinate space of the movie. When a shape added to the display list the shape is drawn relative to the position it was placed at. This makes it easy to draw shapes since you do not have to worry about the final screen coordinates where a given point or vertex will be placed. It also means that the shape definition can be reused or placed at any point on the screen.

Registration Point

Setting the range for the coordinate system can also be used to set the registration point (the origin) for a shape so that its position when it is drawn changes relative to location it is placed on the screen. The following figure shows two identical sized shape but with different coordinate spaces defined in its bounding box which change registration point of the shape when it is drawn on the screen.