PDA

View Full Version : Flash Builder 4 arraycollection question , data property


coimbras
07-24-2009, 06:00 PM
Hello to all


I´m giving my fist steps in Flex.

And created one easy aplication , the begining one , of binding a arraycollection of a HttpRequest to a Tile List and then displaying it.

The problem is that the data property used to get the info from the arraycollection object is not working. Every place I read I get that the data is the way to refer to object info. Is that any change in the new flex framework. What I'm doing wrong. Please give me some feed back



<mx:TileList x="0" y="40" width="100%" height="100%" dataProvider="{photoFeed}">
<mx:itemRenderer>
<fx:Component>
<s:VGroup width="125" height="125" gap="5">

<mx:Image width="75" height="75" source="{data.thumbnail.url}" />
<s:SimpleText text="{data.credit}" />

</s:VGroup>
</fx:Component>
</mx:itemRenderer>
</mx:TileList>

Peter Cowling
07-24-2009, 06:41 PM
<s:List x="0" y="40" width="100%" height="100%" dataProvider="{photoFeed}">

<s:layout>
<s:tileLayout verticalGap="5" horizontalGap="5"
useVirtualLayout="true"/>
<s:layout>

<s:itemRenderer>
<fx:Component>
<s:itemRenderer width="125" height="125">

<s:states>
normal
hovered
selected
</s:states>

<s:VGroup>

<mx:Image width="75" height="75" source="{data.thumbnail.url}" />
<s:SimpleText text="{data.credit}" />

</s:VGroup>

</s:itemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>



Note that the states need inserting and that there are likely some typos, as I just types this straight in.

coimbras
07-24-2009, 07:22 PM
Ok.. Exactly.. It´s Working

Just 2 points I need to understand if you can explain me.

1 - Why the need of the states inside the itemRenderer of the List ???? If I´m not going to define any state?? Is a standart to all List Componentes??


2 -Can anyone explain me why I need to add the tag ItemRender, 2 times, before the component and after? What is the reason for that?

And if I decide to use as a Custom MXL Component I just add the first tag defining the external file?

Peter Cowling
07-25-2009, 05:26 PM
1. It is standard to inline itemrenderer renderers within a list that are not already extending another component.

2. I guess - I have resisted checking this out so far - that it is because itemrenderer must subclass an mxml component. So what you are doing is declaring you want an itemrenderer, creating the component as a basis for subclassing the itemrenderer, and then actually declaring the itemrenderer you use.