Flex Vs FlashDevelop?

I’m a total newbie and can’t quite get a handle on what Flex actually is - I’m using FlashDevelop (cos it’s free!) with Flash CS4. Is FlashDevelop basically the opensource version of Flex or is it something completely different again? Or is that what AIR is? Or am I completely off on a tangent?