Problem with Selection.setFocus

Hey all,

I’m working on a chat application which works with smilies. The smilies themselves work great, and I’m now at the point of adding a field with the 20 most popular smilies. When a user clicks them, the code (":-)" or “:p” for instance) gets added to the textfield. The problem is that after adding this code, I can’t seem to get the focus back on the input field, resulting in the user having to click it again.

Currently I have the following:

on(release) {
	_root.Application.msg.text += " :-)";
	Selection.setFocus("_root.Application.msg");
	Selection.setSelection(_root.Application.msg.length, _root.Application.msg.length);
	Selection.setFocus("_root.Application.msg");
}

I use the setSelection to get the cursor on the final position of the input field. The second setFocus doesn’t seem to put the focus back though…

Any help would be highly appreciated.