1 Reply Latest reply on Mar 9, 2007 11:27 AM by ntsiii

    item renderer implemented as an .AS not .mxml

    vbdive
      Can someone please help - I have been trying to figure this out for the last week and no luck. There are lots of examples using MXML, but I really need to get this working mainly using ActionScript. Appreciate the help!

      1. I have a web service: http://www.mysite.com/cgi?getThumb=name_of_thumb.jpg
      2. I would like to display this list of thumbnails inside a HorizontalList.

      Below is my source for Thumb.as:
      // ActionScript file
      // Thumb.as
      package
      {
      import mx.containers.Canvas;
      import mx.controls.Image;

      public class Thumb extends Canvas
      {
      var img:Image;

      public function Thumb():void
      {
      this.x = 100;
      this.y = 100;
      img = new Image();
      img.percentHeight= 100;
      img.percentWidth = 100;
      img.source = data.imgURL;
      this.addChild(img);
      }
      }
      }

      My main mxml application is as follows:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="main()">
      <mx:Script>
      <![CDATA[
      import mx.collections.ArrayCollection;
      import mx.controls.HorizontalList;
      public function main():void
      {
      var hl:HorizontalList = new HorizontalList();
      hl.percentHeight = 100;
      hl.percentWidth = 100;
      hl.x = 0;
      hl.y = 0;

      var img1:Object = {imgURL:" http://www.mysite.com/cgi?getThumb=thumb1.jpg"};
      var array1:Array = new Array(1);
      array1[0] = img1;
      var imgList:ArrayCollection = array1 as ArrayCollection;
      hl.dataProvider=imgList;
      hl.itemRenderer = new ClassFactory(Thumb);
      this.addChild(hl);
      }
      ]]>
      </mx:Script>
      </mx:Application>