3 .font Arial "../doc/Arial.swf"
4 .edittext et width=600 height=50 color=black font=Arial size=40pt border text=test variable=text_selection
8 .swf TextBox document.swf
15 str = TextBox.getTextSnapShot();
16 str.setSelectColor(0xffff00);
19 TextBox.onMouseDown = function() {
20 firstChar = str.hitTestTextNearPos(_xmouse, _ymouse, 0);
21 str.setSelected(0, str.getCount(), false);
22 _root.text_selection = str.getSelectedText(true);
25 TextBox.onMouseUp = function() {
27 lastChar = str.hitTestTextNearPos(_xmouse, _ymouse, 0);
28 if (firstChar != lastChar) {
29 if (firstChar < lastChar) {
30 str.setSelected(firstChar, lastChar+1, true);
31 _root.text_selection = str.getSelectedText(true);
33 str.setSelected(lastChar, firstChar+1, true);
36 _root.text_selection = str.getSelectedText(true);
42 TextBox.onMouseMove = function() {
44 str.setSelected(0, str.getCount(), false); //unselect everything
46 lastChar = str.hitTestTextNearPos(_xmouse, _ymouse, 0);
47 if (firstChar < lastChar) {
48 str.setSelected(firstChar, lastChar+1, true);
49 } else if(lastChar >= 0) {
50 str.setSelected(lastChar, firstChar+1, true);
52 _root.text_selection = str.getSelectedText(true);