.flash version=6 bbox=1024x180 background=#c0c0ff .font arial filename=Arial.ttf .text line1 font=arial text="select me! select me! select me!" color=black size=50% .text line2 font=arial text="abcdefghijklmnopqrtuvwxyz" color=black size=50% .text line3 font=arial text="The quick brown fox jumps over the lazy dog" color=black size=50% .frame 1 .sprite TextBox .put line1 x=0 y=50 .put line2 x=0 y=100 .put line3 x=0 y=150 .end .put TextBox .frame 2 .action: str = TextBox.getTextSnapShot(); str.setSelectColor(0xffff00); firstChar = -1; TextBox.onMouseDown = function() { firstChar = str.hitTestTextNearPos(_xmouse, _ymouse, 0); str.setSelected(0, str.getCount(), false); _root.text_selection = str.getSelectedText(true); }; TextBox.onMouseUp = function() { if (firstChar >= 0) { lastChar = str.hitTestTextNearPos(_xmouse, _ymouse, 0); if (firstChar != lastChar) { if (firstChar < lastChar) { str.setSelected(firstChar, lastChar+1, true); _root.text_selection = str.getSelectedText(true); } else { str.setSelected(lastChar, firstChar+1, true); } } _root.text_selection = str.getSelectedText(true); firstChar = -1; lastChar = -1; } }; TextBox.onMouseMove = function() { if(firstChar != -1) { str.setSelected(0, str.getCount(), false); //unselect everything lastChar = str.hitTestTextNearPos(_xmouse, _ymouse, 0); if (firstChar < lastChar) { str.setSelected(firstChar, lastChar+1, true); } else if(lastChar >= 0) { str.setSelected(lastChar, firstChar+1, true); } _root.text_selection = str.getSelectedText(true); } }; .end .frame 3 .action: Stop(); .end .end