MXML graphics are a collection of classes that define graphic
elements in an application. MXML graphics tags support interactivity.
They can be children of any container or group, can be declared
as children of the root Application tag, and can be added to the
application’s display list.
Most MXML graphics classes are in the mx.graphics and spark.primitives packages.
These classes include shapes, strokes, colors, fills, and gradients.
MXML graphics tags have an implicit depth order. The order in
which elements are defined defines their depth. Each tag is effectively
drawn above its previous sibling. Children are drawn above their
parents.
The following example uses MXML graphics to draw a filled rectangle:
The executing SWF file for the previous example is shown below:
Because the classes that make up MXML graphics are part of the
Flex SDK, you can reference them from within ActionScript or from
other components. The following example changes the rectangle’s
color when you click the button:
The executing SWF file for the previous example is shown below:
All MXML graphics classes have backing ActionScript implementations.
This means that every MXML tag has a corresponding ActionScript
class that the compiler maps the tag to during compilation. The
table in Graphics classes and elements lists the tags and their backing ActionScript
classes. You can use the classes in ActionScript directly in your <fx:Script> blocks
to draw vector based graphics instead of the MXML tags. For more
information, see Using
the drawing API.