Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何获得所选输入文本的长度数?
就像,如果文本选择了 2 个字符,那么它会返回长度为 2。
那可能吗?
谢谢。
使用 textfield.selectionBeginIndex 和 textfield.selectionEndIndex 计算当前选择的字符数。
var selected:int = field.selectionEndIndex - field.selectionBeginIndex;
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextField.html#selectionBeginIndex