1 Reply Latest reply on Jul 19, 2007 3:43 PM by schjlatah

    programmatically setting itemRenderer

    schjlatah Level 1
      I am trying to pass an item renderer to a tile list inside of a component so that I can re-use this component again in a different place. The only difference between the two is the itemRenderer.

      What works:

      <!-- ============================================================ -->
      <mx:TileList
      id="lookupTileList"
      itemRenderer="com.company.components.ir1"/>
      <!-- ============================================================ -->

      What I'd like to do:

      /* =============================================================== */
      public function set renderer (item:*):void
      {
      lookupTileList.itemRenderer = item;
      }
      //then in a different package pass in item like this
      ..
      import com.company.components.ir1;
      var temp:ComponentHoldingTileList = new ComponentHoldingTileList();
      temp.renderer = new ir1();
      /* =============================================================== */

      Give it to me strait Doc: how far off am I?
      Do I need to use itemRendererToIndex or something else like that?
      All help is appreciated.
        • 1. Re: programmatically setting itemRenderer
          schjlatah Level 1
          Mike from FlexCodes was able to help me out on this one. Could *not* have gotten this working w/o his help.

          <mx:Script>
          <![CDATA[
          [Bindable("itemRendererChanged")]

          public function get itemRenderer():IFactory
          {
          return _itemRenderer;
          }

          public function set itemRenderer(value:IFactory):void
          {
          if (_itemRenderer != value)
          {
          _itemRenderer = value;
          itemRendererChanged = true;
          invalidateProperties();
          dispatchEvent(new Event("itemRendererChanged"));
          }
          }

          override protected function commitProperties():void
          {
          super.commitProperties();

          if (itemRendererChanged)
          {
          lookupTileList.itemRenderer = _itemRenderer;
          lookupTileList.invalidateList ();
          itemRendererChanged = false;
          }
          }

          ]]>
          </mx:Script>

          <mx:TileList
          id="lookupTileList"/>