samedi 16 février 2008

Flex: how-to access remote data (xml) through a proxy?

Flash player (used by Flex) has a very strict security policy: it's not possible to access public data from another domain than the one where your swf stands (unless a crossdomain.xml file is present on the distant server you want to access).


If the crossdomain file doesn't exist it is always possible to copy a minimal proxy file on your server (where your swf is present). This way flash player will communicate locally with the proxy, the proxy will give the result back to flashplayer, and there won't be any remote domain seen by flashplayer.

How-to use a proxy with Flex and Action Script3? (code and example)

http://docs.google.com/Doc?id=dgqhgsgm_154gfhwj5cn

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