Password Authentication is Flash

it there any way to create an advanced password authentication in flash ?
I saw the tutorial here :http://www.kirupa.com/developer/flash5/ifelse.htm
but I want to take it to the next level an create a more advanced authentication that will draw the passwords from a database or something external ( asp, php ).
what is the most secure way to do it ?