Selection class

Let’s say we have an input text named “txt” and a button named “but”. I select a part of the text from the input text and after… i click the button and it must tell me the positions of the selection (beggining, end). How to do this? If i press the button, the focus goes on the button so i lose the selection… help…

on(release) {
	trace(Selection.getBeginIndex());
	trace(Selection.getEndIndex());
}

This is one of my codes that doesn’t work. Please help…