下面是main.mxml:
- <? xml version = " 1.0 " encoding = " utf-8 " ?>
- < FxApplication name = " FxList_itemRenderer_test "
- xmlns = " http://ns.adobe.com/mxml/2009 " >
- < layout >
- < BasicLayout />
- </ layout >
- < Declarations >
- < ArrayList id = " arrList " >
- < Object firstName = " Ryan "
- lastName = " Frishberg "
- url = " http://frishy.blogspot.com/ " />
- < Object firstName = " Ely "
- lastName = " Greenfield "
- url = " http://www.quietlyscheming.com/blog/ " />
- < Object firstName = " Chet "
- lastName = " Haase "
- url = " http://graphics-geek.blogspot.com/ " />
- < Object firstName = " Alex "
- lastName = " Harui "
- url = " http://blogs.adobe.com/aharui/ " />
- < Object firstName = " Joan "
- lastName = " Lafferty "
- url = " http://butterfliesandbugs.wordpress.com/ " />
- < Object firstName = " Gordon "
- lastName = " Smith "
- url = " http://blogs.adobe.com/gosmith/ " />
- < Object firstName = " Deepa "
- lastName = " Subramaniam "
- url = " http://iamdeepa.com/blog/ " />
- < Object firstName = " Rob "
- lastName = " Vollmar "
- url = " http://flexspaghetti.wordpress.com/ " />
- </ ArrayList >
- </ Declarations >
- < FxList id = " list "
- dataProvider = " {arrList} "
- itemRenderer = " ResizingItemRenderer "
- horizontalCenter = " 0 "
- top = " 20 "
- width = " 250 " />
- </ FxApplication >
下面是ResizingItemRenderer.mxml的代码:
- <? xml version = " 1.0 " encoding = " utf-8 " ?>
- < ItemRenderer name = " ResizingItemRenderer "
- xmlns = " http://ns.adobe.com/mxml/2009 " >
- < states >
- < State name = " normal " />
- < State name = " hovered " />
- < State name = " selected " />
- </ states >
- <!-- hover/select highlight -->
- < Rect left = " 0 " right = " 0 " top = " 0 " bottom = " 0 " >
- < fill >
- < SolidColor color = " {contentBackgroundColor} " />
- </ fill >
- < fill . hovered >
- < SolidColor color = " {rollOverColor} " />
- </ fill . hovered >
- < fill . selected >
- < SolidColor color = " {selectionColor} " />
- </ fill . selected >
- </ Rect >
- < VGroup left = " 3 " top = " 3 " right = " 10 " bottom = " 3 " >
- < TextGraphic content = " {data.firstName} {data.lastName} "
- fontWeight = " bold " />
- < TextGraphic content = " {data.url} "
- includeIn = " selected " />
- </ VGroup >
- </ ItemRenderer >