1 Reply Latest reply on Aug 18, 2011 12:56 AM by Shongrunden

    setting component state properties from actionscript

    GerryKoh

      hello,

       

      i have a list itemrenderer with a few labels and an image in it.  i want to pull the colors for the various states of the labels from a stylesheet.

       

      i store the colors in the itemrenderers preinit event handler:

       

                  protected function itemrenderer1_preinitializeHandler(event:FlexEvent):void
                  {
                      // read the colors from the stylesheet
                      this.descriptionNormalColor = getStyle("descriptionNormalColor") as uint;
                      this.descriptionHoveredColor = getStyle("descriptionHoveredColor") as uint;
                      this.descriptionSelectedColor = getStyle("descriptionSelectedColor") as uint;
                  }

       

      normally in mxml i would use something like this to set the colors for the various states:

       

                  <s:Label
                      color="{this.descriptionNormalColor}"
                      color.selected="{this.descriptionSelectedColor}"
                      />

       

      however, i usually try to avoid using bindings for things that are only set once. in my item renderer i might have 5 or 10 bindings to set all the colors * 10 or 20 list items visible at once = tons of unnecessary bindings.

       


      is there a way i can set these state properties through actionscript?

       

       

      thanks,

       

       

       

      g