I have a number of TextInput components on a form, and each input can
have a different font, which is chosen from a combo box. The combo box
definition looks something like this
<mx:ComboBox id="fontType" dataProvider="{fonts}" change="changeFont()">
</mx:ComboBox>
the fonts data source is defined like this
[Bindable]
private var fonts:ArrayCollection = new ArrayCollection(
[
{label:"Arial", data:"Arial"},
{label:"Blue Highway", data:"BlueHighway"},
{label:"High Strung", data:"HighStrung"}
]);
Pretty straight forward. My issue arises when I move from TextInput to
TextInput. I want the ComboBox to reflect the font of the TextInput
with the focus. The problem is that I can't work out a better way to
do that than this:
for(var index:int = 0; index < fonts.length; index++)
{
if(fonts[index].data == currentFocus.fontFamily)
{
fontType.selectedItem = fonts[index];
}
}
where currentFocus is the TextInput and fontFamily is a function that
returns the current font of that control (actually the TextInput
controls are housed in custom components that supply the fontFamily
function but that isn't important here).
Is there an easier way to do this?
Dale