1 Reply Latest reply on May 7, 2009 1:31 PM by Gregory Lafrance

    How to use actionscript to set this stylesheet

    webvalue

      Hi I am having difficulty understanding hwo to use the stylesheet in actionscript. In particular, how to place a stylesheet like the one below in actionscript class and use it?

       

          <mx:Style>
              @font-face{
                  fontFamily: arialEmbeddedFont;         
                  src: local("Arial");
                  fontWeight: normal;
              }
             
              .textFontStyle {
                  fontFamily: arialEmbeddedFont;
                  fontSize: 50;
                  color: #000066;
                  fontAntiAliasType: advanced;
                  fontGridFitType: pixel;
                  fontSharpness: -400;
                  fontThickness: 100;
              }
          </mx:Style>

        • 1. Re: How to use actionscript to set this stylesheet
          Gregory Lafrance Level 6

          That is MXML. You can't use that in ActionScript.

           

          Here is how you do it in AS:

           

          var style:StyleSheet = new StyleSheet();

           

          var styleObj:Object = new Object();
          styleObj.fontSize = "bold";
          styleObj.color = "#FF0000";
          style.setStyle(".darkRed", styleObj);

           

          var tf:TextField = new TextField();
          tf.styleSheet = style;
          tf.htmlText = "<span class = 'darkRed'>Red</span> apple";

           

          addChild(tf);