<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 { //這里用正則表達(dá)式來(lái)決定是否找到任何通過(guò)模板一個(gè)“<”符號(hào),接上任何字字母,接上另一個(gè)“〉”符號(hào)測(cè)試的HTML 標(biāo)簽: var regexp:RegExp = /<.+/w.>/; if(regexp.test(str)) { textArea.htmlText = str; } else { textArea.text = str; } }