tags:

views:

14

answers:

1

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.

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
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
That happens internally - most probably in the constructor of the `Sprite` class - we don't have access to that code.
Amarghosh