2 Replies Latest reply on Mar 31, 2010 10:21 AM by giant frog

    cannot set the properties of an itemrenderer in sdk 4

    giant frog Level 1

      Hi,

       

      I have a project working in sdk 3 that creates an item renderer for a grid, and passes the field index to the renderer. In sdk 4, the

      property is null. Is this a bug? (code truncated)

       

      <?xml version="1.0"?>

       

      <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" horizontalScrollPolicy="off" verticalScrollPolicy="off" horizontalGap="5" paddingLeft="6" implements="mx.core.IFactory">

       

          <mx:Script>

       

              <![CDATA[

       

                  [Bindable] public var fieldIndex:int = -1;

       

                  ........

       

       

                  public function newInstance():*

       

                  {

       

                      return new statusItem();

       

                  }

       

       

                  override public function set data(value:Object):void { 

       

                      super.data = value;

       

                      var status:String = "";

       

                      var statusImg:String = "";

       

       

       

       

       

                      if (value != null && value.length > 0 && fieldIndex > -1)   {

       

                          status = value[fieldIndex];       

       

                          if (status != null && status.length > 0) {

       

                              switch(status.toLowerCase()) {

       

                                  case "open" : img.source = Icon1;

       

                                              break;

       

                                  case "closed" : img.source = Icon2;

       

                                      break;

       

                                  default : img.source = Icon9;

       

                                      break;

       

       

                              }                       

       

                          }

       

                      }

       

                      else {

       

                          img.source = errorIcon;

       

                      }

       

                  }

       

       

       

              ]]>

       

          </mx:Script>

       

          <mx:Image id="img" source="{blankIcon}" verticalAlign="middle" width="10" height="10" />

       

          <mx:Label id="lbl" text="{data[fieldIndex]}" />

       

      </mx:HBox>

       

       

      .....

       

      parent code

       

      var sRenderer:ClassFactory = new ClassFactory(statusItem);
                                                  sRenderer.properties = { fieldIndex: x };
                                                  dgc.itemRenderer = sRenderer;

       

       


      It is simple code that works in version 3, but not in version 4.

       

      thanks,

       

      Jon