Determine text width?

Anybody know of a way to programmatically determine – given a single line block of text, its font, its size, etc. – the width in pixels of the text block?

Maybe this wouldn’t be something you’d do in Flash, I dunno.

Thanks!