<mx:VBoxxmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300"> <mx:Script> <![CDATA[ privatevar htmlStr1:String = '<b>Header</b><br/>Hello.<i>Hello.</i> <font color="#ff0000" size="15">RED</font>'; privatevar htmlStr2:String = "<ul><li>Item 1</li><li>Item 2</li><li>Item3</li></ul>"; privatevar textStr1:String = "It is a long established fact that a readerwill be distracted by the readable content of a page when looking at its layout, if say the amount of text > 100."; privatevar textStr2:String = " We can use <<String>> to indicate in Erlang that the values being passed are Strings"; privatefunction setNewText():void { determineTextType(changeText.selectedItem.value.toString()); } privatefunction determineTextType(str:String):void { //这里用正则表达式来决定是否找到任何通过模板一个“<”符号,接上任何字字母,接上另一个“〉”符号测试的HTML 标签: var regexp:RegExp = /<.+/w.>/; if(regexp.test(str)) { textArea.htmlText = str; } else { textArea.text = str; } }