在Adobe Flex3中,这会导致问题。
textArea.setSelection( textArea.htmlText.indexOf( 'testString' ), textArea.htmlText.indexOf( 'testString' ) + 10 );这会将光标放在错误的位置,因为indexOf会考虑HTML标记,而setSelection不会。
有人知道怎么做吗?一种简单的方法是/<^>*>/g正则表达式,但这并不是每次都能做到这一点。
请帮帮我!
安德鲁
发布于 2011-03-22 04:04:36
试着这样做:
textArea.setSelection( textArea.text.indexOf( 'testString' ), textArea.text.indexOf( 'testString' ) + 10 );通过使用“text”属性而不是“htmlText”,您可以删除html标记。此外,我不会使用2个索引搜索,这是不有效的。试试这个:
var string:String = 'testString';
var index:int = textArea.text.indexOf(string);
textArea.setSelection(index, index + string.length);https://stackoverflow.com/questions/5381331
复制相似问题