1 Reply Latest reply on Mar 21, 2008 6:16 AM by Gregory Lafrance

    Using a bitmap object as a item renderer in a datagrid

    flashharry! Level 1
      I have a UIComponent grabbed has a bitmap, and stored in an array collection.

      I want to display a thumbnail in a datagrid, I can make a itemRenderer for an image with a local or remote file as a source. But how do I use the bitmap in the array collection in an item renderer.

      Thanks
      Dean
        • 1. Re: Using a bitmap object as a item renderer in a datagrid
          Gregory Lafrance Level 6
          Here is an example with a HorizontalList:

          <?xml version="1.0" ?>
          <!-- itemRenderers\htlist\myComponents\Thumbnail.mxml -->
          <mx:VBox xmlns:mx=" http://www.adobe.com/2006/mxml"
          horizontalAlign="center"
          verticalGap="0" borderStyle="none" backgroundColor="white" >

          <mx:Image id="image" width="60" height="60" source="{data.image}"/>
          <mx:Label text="{data.name}" width="120" textAlign="center"/>
          <mx:Label text="${data.price}" fontWeight="bold"/>
          </mx:VBox>
          --------------------------------------------------------------------
          <?xml version="1.0"?>
          <!-- itemRenderers\htlistMainlistThumbnailRenderer.mxml -->
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">

          <mx:Model id="catalog" source="catalog.xml"/>

          <mx:HorizontalList id="myList"
          columnWidth="125"
          rowHeight="125"
          columnCount="4"
          dataProvider="{catalog.product}"
          itemRenderer="myComponents.Thumbnail"/>

          <mx:LinkButton label="Product images courtesy of Lavish"
          click="navigateToURL(new URLRequest(' http://www.shoplavish.com'), '_blank')"/>
          </mx:Application>
          ---------------------------------------------------------------------
          <?xml version="1.0"?>
          <catalog>
          <product id="1">
          <name>USB Watch</name>
          <price>129.99</price>
          <image>assets/products/usbwatch.jpg</image>
          <thumbnail>assets/products/usbwatch_sm.jpg</thumbnail>
          </product>
          <product id="2">
          <name>007 Digital Camera</name>
          <price>99.99</price>
          <image>assets/products/007camera.jpg</image>
          <thumbnail>assets/products/007camera_sm.jpg</thumbnail>
          </product>
          <product id="3">
          <name>2-Way Radio Watch</name>
          <price>49.99</price>
          <image>assets/products/radiowatch.jpg</image>
          <thumbnail>assets/products/radiowatch_sm.jpg</thumbnail>
          </product>
          <product id="4">
          <name>USB Desk Fan</name>
          <price>19.99</price>
          <image>assets/products/usbfan.jpg</image>
          <thumbnail>assets/products/usbfan_sm.jpg</thumbnail>
          </product>
          <product id="5">
          <name>Caffeinated Soap</name>
          <price>19.99</price>
          <image>assets/products/soap.jpg</image>
          <thumbnail>assets/products/soap_sm.jpg</thumbnail>
          </product>
          <product id="6">
          <name>Desktop Rovers</name>
          <price>49.99</price>
          <image>assets/products/rover.jpg</image>
          <thumbnail>assets/products/rover_sm.jpg</thumbnail>
          </product>
          </catalog>