If you want to get really technical, it doesn't really matter as long as you compile your code into ABC bytecode which is basicly as low level as it gets before Flash compiles/interprets the code. In theory, this would mean that you could write a compiler for most any language.
However, I'm guessing you're asking for something that's more readily available. In that case, ActionScript is your friend. There is no reason to go with AS2 as it is for all intents and purposes a dead end. The player falls back to AVM1 for AS2 code which is much slower than AVM2 which runs AS3 code. AS2 also is a much looser language than AS3. Sometimes that's a good thing, but generally it's like running barefoot across a field of glass.
You could have a look at Flex, which combines MXML and AS3. MXML is a markup language for declaratively defining components (visual and non-visual). While MXML is a markup language, it is not similar to HTML at all. However, it does help knowing HTML (or any other markup language, such as XML) when faring into the world of MXML. The Flex compiler interprets the MXML code and generates AS3-classes which are subsequently compiled into bytecode.
Just as raptors tell above, you can also perform regular http calls. While this is most certainly useful, it's not something I suggest for logic that really do belong client side.