Flex isn't really a like-for-like replacement. If you have a need for a level of interactivity and animation that does beyond what is possible with HTML and CSS, Flex is a good choice.
The programming language is ActionScript 3.0, and there's a mark-up language layer on top of that called MXML. It might be worth having a read here:
http://jodieorourke.com/view.php?id=106&blog=news