2010-05-21 87 views
1

我想Flex 4中幫助與Flex 4中創建自定義的ItemRenderer

這裏創建一個自定義的ItemRenderer的TileList的我的渲染器:

<?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="true"> 

    <mx:Image x="0" y="0" source="../images/blank-offer.png" width="160" height="144" smoothBitmapContent="true"/> 
    <s:Label x="5" y="20" text="{data.title}" fontFamily="Verdana" fontSize="16" color="#696565" width="155"/> 
    <s:Label x="5" y="42" text="{data.description}" fontFamily="Verdana" fontSize="8" color="#696565" width="154"/> 
    <mx:Text x="3" y="59" text="{data.details}" fontFamily="Verdana" fontSize="8" color="#696565" width="157" height="65"/> 
    <mx:Text x="3" y="122" text="{data.disclaimer}" fontFamily="Verdana" fontSize="5" color="#696565" width="157" height="21"/> 

</s:ItemRenderer> 

這裏是我的平鋪列表:

<mx:TileList x="0" y="0" width="100%" height="100%" id="tileList" creationComplete="tileList_creationCompleteHandler(event)" dataProvider="{getDataResult.lastResult}" labelField="title" itemRenderer="renderers.OfferLibraryListRenderer"></mx:TileList> 

當我運行應用程序,我得到這個錯誤:

錯誤#1034:類型強制失敗:不是C將renderer :: OfferLibraryListRenderer @ 32fce0a1轉換爲mx.controls.listClasses.IListItemRenderer。

回答

0

我認爲在Flex4中,您應該使用<s:List>組件而不是<mx:TileList>。我試過這種方式,它的工作原理。