Trim away heading and trailing spaces in flash input text field

Hi,

I need to trim away away all the extra spaces that a users types into my input text field. I know that there are a few ways possible, but i’m not sure how to go about doing it. Could someone help?

Thanks!