# Converting (casting?) TextFormat object from ComboBox

**URL:** <https://forum.kirupa.com/t/converting-casting-textformat-object-from-combobox/267386>\
**Category:** Uncategorized\
**Created:** [July 31, 2008, 2:27pm UTC](https://forum.kirupa.com/t/converting-casting-textformat-object-from-combobox/267386 "2008-07-31T14:27:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![partimer](https://avatars.discourse-cdn.com/v4/letter/p/f1d935/32.png) [@partimer](https://forum.kirupa.com/u/partimer)\
**Post date:** [July 31, 2008, 2:27pm UTC](https://forum.kirupa.com/t/converting-casting-textformat-object-from-combobox/267386/1 "2008-07-31T14:27:35Z")

</div>

I’ve a textfield that can have different TextFormats applied to it - these formats are in a combo:

[SIZE=1][COLOR=darkred]**var comboProp:Array = [{label:“Body style 1”, data:myFormat1}, {label:“Body Sytle 2”, data:myFormat2}, …etc**[/COLOR][/SIZE]

The listener function needs to set the TextFormat of the field to the chosen combo value:  
[SIZE=1][COLOR=darkred]**field\_txt.setTextFormat(ComboBox(evt.currentTarget).selectedItem.data);**[/COLOR][/SIZE]

but I’m getting all sorts of errors - notably:

[SIZE=1]**cannot convert “[object TextFormat]” to flash.text.TextFormat.**[/SIZE]  
**[SIZE=1][/SIZE]**  
I’ve tried appending …data.getTextFormat() to the end of the above but no joy. I guess this is a simple schoolboy error but if anyone can help I’d most appreciate it!

Cheers,  
Pt
