I am trying to use a custom cell renderer with the <mx:TileList> tag.
The cell renderer displays a dynamically loaded JPG file in each tile.
Everything works great at first, but if I try to change the itemWidth
and itemHeight properties after the control is initially drawn all my
images disappear. That is, until you scroll the TileList down and up
again!?

Does anyone have suggestions on how to fix this redraw problem? I've
included in this email the simplest example I could come up with to
demonstrate the problem. Just save the code below in two different mxml
files as noted. You'll need to supply your own images as called for in
the "productList" array.

Thanks in advance for any guidance you can offer!

Kris

=== index.mxml ===

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"; xmlns="*"
>

        <mx:Script>
        <![CDATA[
                function doResize()
                {
                        tileList.itemWidth = tileList.itemWidth + 20;
                        tileList.itemHeight = tileList.itemHeight + 20;
                }
        ]]>
        </mx:Script>
        
        <mx:Array id="productList">
                <mx:Object label="Item 1"
imageUrl="images/single1_th.jpg" />
                <mx:Object label="Item 2"
imageUrl="images/single2_th.jpg" />
                <mx:Object label="Item 3"
imageUrl="images/single3_th.jpg" />
                <mx:Object label="Item 4"
imageUrl="images/single4_th.jpg" />
        </mx:Array>
        
        <mx:HBox>
                <mx:Panel title="Products" width="480" height="320">
                        <mx:TileList id="tileList"
                                dataProvider="{productList}"
                                cellRenderer="MyCellRenderer"
                                width="100%"
                                height="100%"
                                itemWidth="100"
                                itemHeight="100"
                        />
                        <mx:ControlBar>
                                <mx:Button label="resize"
click="doResize(event)" />
                        </mx:ControlBar>
                </mx:Panel>
        </mx:HBox>
        
</mx:Application>

========


==== MyCellRenderer.mxml ====

<?xml version="1.0" encoding="utf-8"?>

<mx:VBox xmlns:mx="http://www.macromedia.com/2003/mxml";>
        
        <mx:Script>
        <![CDATA[

                var dataObject:Object;
                
                 function setValue(str:String, item:Object)
                {
                        dataObject = item;
                }
         ]]>
        </mx:Script>

        <mx:Image id="theImage" width="100%" height="100%"
source="{dataObject.imageUrl}" toolTip="{dataObject.label}" />

</mx:VBox>

========


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to