1,禁止复制粘贴控制文本
把文本的可选(selectable)选项设置为false
<mx:Text selectable="false" text="This is an example of a multiline text string in a Text control." />
2,TextArea 输入文字,如果使其自动移动要需要的位置。
if (space.length == wordLength){
txtAnswer.text += " ";
txtAnswer.setSelection(txtAnswer.text.length,txtAnswer.text.length);
}
3,文本全局替换
官方文档:
In the following example, only the first instance of "sh" (case-sensitive) is replaced:
var myPattern:RegExp = /sh/;
var str:String = "She sells seashells by the seashore.";
trace(str.replace(myPattern, "sch"));
// She sells seaschells by the seashore.
In the following example, all instances of "sh" (case-sensitive) are replaced because the g
(global) flag is set in the regular expression:
var myPattern:RegExp = /sh/g;
var str:String = "She sells seashells by the seashore.";
trace(str.replace(myPattern, "sch"));
// She sells seaschells by the seaschore.
In the following example, all instance of "sh" are replaced because the g
(global) flag is set in the regular expression and the matches are not case-sensitive because the i
(ignoreCase) flag is set:
var myPattern:RegExp = /sh/gi;
var str:String = "She sells seashells by the seashore.";
trace(str.replace(myPattern, "sch"));
// sche sells seaschells by the seaschore.