1 Reply Latest reply on Oct 19, 2010 10:15 PM by Shongrunden

    Help making TileList Selectable..Code Included

    flexillu10 Level 1

      I have a list with layout set to TileLayout. Without my itemrenderer i get this behaviour:

       

      As you can see i can select items and they are highlighted in blue.

       

      selected.png

      However when i implement my item renderer, a thumbnail is displayed and i can select the thumbnails but they are not visually selected and are no longer highlighted.

       

      How can i make my item renderer change colour when selected?

       

      Also, i have allow_multiple_selection set to True. Are these items then stored in an array? How do i get access to this list of selected items?

       

       

      here is my List code

       

       

      <s:List id="testlist" x="198" y="256" dataProvider="{imageService.lastResult.images.image}"  itemRenderer="thumbrenderer"  width="912" height="275" includeIn="State1" allowMultipleSelection="true">
              <s:layout>
                  <s:TileLayout requestedColumnCount="3" horizontalGap="10" verticalGap="30"/>   
              </s:layout>

      </s:List>

       

       

       

      And here is my renderer:

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
                      xmlns:s="library://ns.adobe.com/flex/spark"
                      xmlns:mx="library://ns.adobe.com/flex/mx"
                      autoDrawBackground="false" width="250" height="265">
         
          <mx:Image id="thumb" x="9" y="6" width="250" height="265" source="{data.thumburl}" click="thumb_clickHandler(event)"/>
         
          <fx:Script>
              <![CDATA[
                  import flashx.textLayout.factory.TruncationOptions;
                 
                  import mx.controls.Alert;
                  import mx.events.ItemClickEvent;

       

                  protected function thumb_clickHandler(event:MouseEvent):void
                  {
                      var ev:ItemClickEvent = new ItemClickEvent(ItemClickEvent.ITEM_CLICK, true);
                      ev.item = data;
                      ev.index = itemIndex;
                      Alert.show(ev.item.imageurl);
                      dispatchEvent(ev);
                  }

       

             
                 
                 
              ]]>
          </fx:Script>
         
         
         
      </s:ItemRenderer>