2 Replies Latest reply on May 13, 2006 12:43 PM by MarkSLC

    Aargh. Can't change TextArea font attributes.

      I am trying to customize the font and font size of a TextArea component, but no matter what I try, the text always shows in the default 10 point "_sans".

      I referred to Macromedia's official reference book, "Using ActionScript 2.0 Components with Macromedia FLASH 8," and tried every example from pp1378-1382, but nothing works. The font / font size refuses to budge from the default.

      This didn't work:
      _global.styles.TextInput.setStyle("fontFamily", "Bank Gothic") ;

      This didn't work:
      import mx.styles.CSSStyleDeclaration;
      _global.styles.TextArea = new CSSStyleDeclaration();
      _global.styles.TextArea.setStyle("fontFamily", "Bank Gothic");

      This didn't work:
      _global.styles.TextArea.fontFamily= "Bank Gothic";

      * * *

      What the heck is going on?? I am using Flash 8 Pro on a Mac.

        • 1. Re: Aargh. Can't change TextArea font attributes.
          TimSymons Level 1
          This code worked for me.

          import mx.styles.CSSStyleDeclaration;
          _global.styles.TextArea = new CSSStyleDeclaration();
          _global.styles.TextArea.setStyle("fontFamily", "Times New Roman");
          _global.styles.TextArea.setStyle("fontSize", 22);

          When I had the component in the first frame and set it to export in the first frame.

          It did not work under the following conditions (maybe one applies to you):

          1) placed component on frame 10 but put code on frame 1.
          2) placed compoenent and code on frame 1 but change publish settings to load components on frame 10 and left the "Export in first frame" checked.
          3) Unchecked "Export in first frame", set components to load on frame 10 in publish settings but placed component and code on frame 1.

          • 2. Re: Aargh. Can't change TextArea font attributes.
            MarkSLC Level 1
            Thanks, Tim, for sharing the code and the tips. I tried it out but still came up with the default font / font size. There's something in my app that must be interfering. Dunno. But I did ultimately find success by going the style sheet route.

            1. Dragged a textarea component to the stage, gave it the instance name "my_textarea".

            2. Put the following code at the top of the file:
            var my_styles = new TextField.StyleSheet();
            my_styles.setStyle("my_style", {fontFamily:'MrsEavesRoman', fontSize:'22px'});
            my_textarea.styleSheet = my_styles;

            3. Used this code to fill the textarea with text in the custom font and font size:
            my_textarea.text = "<my_style>"+"This is the text that will appear in the textarea."+"</my_style>";