0 Replies Latest reply on Jan 27, 2010 11:31 AM by Woodifer01

    Custom AS3 ItemRenderer

    Woodifer01

      I built a custom ItemRenderer using MXML and it worked great.  I am trying to rewrite it in AS3 by extending UIComponent.  I am new to writing custom classes so bare with me.   I have a list with a dataProvider with twitter data.  I can not seem to get access to this data on my AS3 class.  When I try to access it, it errors out (Error #1009: Cannot access a property or method of a null object reference.) Any ideas on how to properlay access the data from the dataProvider? Here is what I have so far:

       

      // ActionScript file
      package components
      {

       

           import mx.core.UIComponent;
           import mx.core.IDataRenderer;
           import mx.controls.listClasses.IListItemRenderer
           import flash.utils.IDataInput;   
           import mx.controls.Image;

       

         
          public class ModifiedList extends UIComponent implements IListItemRenderer, IDataRenderer
          {
              private var _data:Object;  
              private var img:Image;
             
              public function ModifiedList()
              {
                  super();       
              }
             
              override protected function createChildren():void
              {
                  super.createChildren();
                  img = new Image();
                  //img.source = data.link[1].href;
                  //this.addChild(img);
                  trace(_data.link[1].href);
              }
             
               protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
               {
                   super.updateDisplayList(unscaledWidth, unscaledHeight);
               }
              
               protected override function commitProperties():void
               {
                   super.commitProperties();
               }
              
               protected override function measure():void
               {
                   super.measure();
               }       
                  
              public function get data():Object
              {
                  return _data;
              }       
             
              public function set data(value:Object):void
              {
                  _data = value;           
              }       
          }
      }