<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; } }