I'm trying to understand how the Flex framework draws objects (Button, Label, Image, etc.). The Button class seems to draw itself by addChild()ing its ProgrammaticSkin. However, where in the framework is the Graphics object being passed around in the hierarchy to achieve the drawing. I want to get to the level of 2D API.
views:
14answers:
1
A:
There is no single global graphics object in flash/flex. Every Shape and Sprite (UIComponent is a Sprite) has a graphics
object of type Graphics that can be drawn on. In a flex app, programmatic drawing should be done in the overriden updateDisplayList method of the component. You should use the component's unscaledWidth
and unscaledHeight
as its bounds while drawing on it.
Amarghosh
2009-10-23 08:22:30
The object that overrides updateDisplayList uses the graphics instance to draw. How is the value for the graphics instance set, and where? Tried to look in the layout code, but was unsuccessful.
flexwheel
2009-10-23 13:45:39
That happens internally - most probably in the constructor of the `Sprite` class - we don't have access to that code.
Amarghosh
2009-10-24 06:33:06