Define Label and value separately for ComboBox data binding
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:VBox>
<mx:Script>
private var htmlStr1:String = '<b>Header</b>';
private var textStr1:String = "this is a test";
private function setNewText():void
{
determineTextType(changeText.selectedItem.value.toString());
}
private function determineTextType(str:String):void
{
var regexp:RegExp = /<.+\w.>/;
textArea.text = String(regexp.test(str));
}
</mx:Script>
<mx:ComboBox id="changeText" dataProvider="{
[{label:'HTML1', value:htmlStr1},
{label:'Text1', value:textStr1}]}" change="setNewText()"/>
<mx:TextArea id="textArea" height="100%"/>
</mx:VBox>
</mx:Application>
Related examples in the same category