Flagstone Software

Flash Concepts - Coordinates & Bounding Boxes

Each visible object in a Flash file has an associated frame or bounding box which has two purposes, 1) it 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 and 2) it also specifies the coordinate system used to draw the object.

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.

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).

Selecting the origin for the bounding box can often make drawing shapes easier. For example when drawing simple quadratic shapes choosing the origin to be one of the vertices makes drawing the shape simple however for shapes with a several sides or circles choosing the origin to be the center of the shape is the easiest approach. The position of the origin within the bounding box can also be used to create different registrations or alignments when the object is added to the display list

The bounding rectangle does not necessarily clip the object when it is drawn. Lines and curves drawn outside of the rectangle will still be displayed. However if the object overlaps with another or is animated only the area within the bounding box will be repainted and pixels painted outside of the box will not be erased resulting in artefacts being left on the screen if an object is removed or its position changed. The exception is of course when the bounding box is defines the frame size of the Flash Player screen and shapes drawn outside of the bounding rectangle will not be displayed.