Centering objects

i was trying to make something up:


_root.maintxt.x = (Stage.width / 2) + (_root.maintxt.width / 2);

where i have a text field named maintxt.

Where it should center the text field by as…

but it doesn’t… anyone got some ideas?