1 Reply Latest reply on Mar 27, 2009 7:34 AM by _Natasha_

    Setting Styles in AS3

    ikas333
      Hi,

      I am trying to set styles on components in AS3 via an external stylesheet because the documentation suggests that using the setStyle method should only be reserved for styles that change at runtime.

      Quote:
      A common mistake that impacts performance is overusing or unnecessarily using the setStyle() method. In general, you need the setStyle() method only when you want to change styles on existing objects. Do not use it when setting up styles for an object for the first time. Instead, set styles in an <mx:Style> block, through an external CSS style sheet, or as global styles.

      Are the styles that can be set via an external stylesheet in AS3 limited to those defined in flash.text.stylesheet? If so, am I correct in thinking that setting styles via a stylesheet is not the way to go as this seems a very limited set? For example I want to set the background color on a TextArea control and padding around a piece of text. The setStyle method works fine but I cannot find a way to apply the same via an external stylesheet.

      TIA

        • 1. Re: Setting Styles in AS3
          _Natasha_ Level 4
          You are right, not all styles can be setted using CSS. In docs there is a flag "CSS Inheritance" for it.
          For example you mention about backgroundColor, this description is
          " backgroundColor
          Type: uint Format: Color CSS Inheritance: no
          Background color of a component."