vendredi 15 février 2008

How to programmatically draw in Flex 3?

I was surprised by the lack of documentation( and working example) for this simple task.

Here's what I've got so far:

  • Flex doesn't like "Shape" objects? replace them with "UIcomponent"
  • a "UI component" must be attached to a container (like a canvas, a panel,...)
  • the shape will be visible when it is added has a child of the container: myCanvas.addChild(myCircle)
Here's an example with 3 buttons (1 to create a rectangle, 1 to create a circle, 1 to move them appart):

Run (right click at runtime then "view source" to see the code):
http://francois.schnell.free.fr/flex/draw/draw.html

Code in plain text:
http://docs.google.com/Doc?id=dgqhgsgm_153dc6cvzf7

4 commentaires:

Cristobal a dit…

muchas gracias!

Rishi Verma a dit…

hey, thanks for this!

Francois Schnell a dit…

You're welcome, I'm glad this is useful :)

David J Barnes a dit…

Thanks bro.