Skip to main content
Known Participant
January 13, 2013
Answered

set fontStyle in dynamic text with a combobox

  • January 13, 2013
  • 1 reply
  • 605 views

hello,

I'm trying to make a combobox so the user can change the fontstyle they input in a dynamic text field.

Right now it says that the properties of fontStyle and setStyle are undefined properties o f TextRenderer and Textfield.

This is what I have so far.

//change font style

fontStyleCombo.prompt = "Font Style";

fontStyleCombo.addItem({label:"Medium"});

fontStyleCombo.addItem({label:"Bold"});

fontStyleCombo.addItem({label:"Italic"});

fontStyleCombo.addItem({label:"Bold Italic"});

fontStyleCombo.addEventListener(Event.CHANGE, setFontStyle);

function setFontStyle(evt:Event):void

{

     var fontStyles:Object = "Bold";

    

     if(fontStyleCombo.selectedIndex > -1)

     {

      fontStyles = fontStyleCombo.selectedItem.data;

     }

      

    var fontStyleFormat:TextRenderer = new TextRenderer();

   

    fontStyleFormat.fontStyle = fontStyles;

   

   

    inputTextRender01.setStyle(fontStyleFormat);

   

}

This topic has been closed for replies.
Correct answer Ned Murphy

What class of object is the Textfield?  If it is a dynamic TextField then it doesn't have properties nor methods such as you are trying to implement.  For  TextField instance you should be using the setTextFormat method along with having defined the different formats to set.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
January 13, 2013

What class of object is the Textfield?  If it is a dynamic TextField then it doesn't have properties nor methods such as you are trying to implement.  For  TextField instance you should be using the setTextFormat method along with having defined the different formats to set.

Known Participant
January 17, 2013

Thanks. I ended up putting the styles in the font face combo box.

Ned Murphy
Legend
January 17, 2013

You're welcome