views:

1132

answers:

5

I am extending VBox to make a Calendar component. What method should I override to add the code to draw itself? What is the difference between all these methods? Is there something I should be putting in each one, or is there a specific method I can just override, add my drawing code, and have it work?

Thanks!

+5  A: 

This white-paper is perhaps the best source of information I have seen on the subject.

Joel Hooks
That was a great read, thanks for sharing!
John Isaacks
+1  A: 

I also recommend this article:

http://maohao.wordpress.com/2009/02/02/6-steps-in-creating-custom-uicomponent-in-flex-halo-framework/

Briefly, if you're doing graphics operations to draw, you'll want to use override updateDisplayList() and call invalidateDisplayList() as necessary; if you're using subcomponents, you'll use commitProperties()/invalidateProperties(). If you're dynamically sized, you'll need measure() and invalidateSize().

Michael Brewer-Davis
+1  A: 

Override updateDisplayList method of UIComponent and do your drawing in it. Use the component's unscaledWidth and unscaledHeight as the bounds for drawing.

Amarghosh
+2  A: 

Deepa's MAX 2008 talk was easily the best and most easily understanding presentation on the topic. It shows exactly how to write components properly in Flex 3.

Gregor Kiddie
A: 

From Adobe Flex 3 Live Docs Advanced Visual Components in ActionScript - great source.

zdmytriv