Hello, here is the scene:
Using Flash Builder 4, SDK 4.1;
An s:List that displays products by category;
The List's dataProvider is an ArrayCollection of products;
An ItemRenderer - a DataRenderer - shows each product; this renderer has several States.
The renderer changes state based on the number of products in the category being displayed.
I need to pass the ArrayCollection's length to the DataRenderer so it knows what state to use.
If anyone has any ideas about this, I would love to hear.
peterent was the guru of ItemRenderers, but I haven't seen his posts recently. Anybody know if he's still with Adobe?
So, where are you, flexHarUI, Gregory Lafrance? This question seems like right up your alley.
Nobody wants to take a shot at this?
I would use a singleton or a static variable to hold the lenght of the arraycollection. since they are available evry where, I can access it in the renderer in the set data method and decide what to show.
List.dataProvider = arrayCollection
StaticPublicVarialbeOfThisClass = arrayCollection.length
in the DataRenderer
currentState = ThatClass.StaticPublicVarialbeOfThisClass == 10 ? "10state":"noneState";
I think saisri2k2's suggestion has put me on the right track, although working on this for the past couple of days has not solved the problem.
If anyone wants to look at this, the project is here, http://www.timos.com/LeCreuset/LeCreuset.html and View Source is enabled. The file you want to look at is src > renderers > ProductThumb.mxml.
If you are looking at source, know that I have tried the following:
None of the above has worked: the filterCount is correct when you select a new category. When you select a category with fewer than 16 products, the tiles change to a state where they are bigger (as they should). But once they have turned bigger, they don not want to return to a state where they should be smaller when you switch to a category with more products. If you try changing categories using the ComboBox you will see this.
So I don’t know what else to try. I have a hunch this may have something to do with the fact that the renderers are recycled when the containing list uses the virtualization (which apparently you can’t turn of in an s:List).
If anyone has any ideas/suggestions, I would love to hear them.
Thanks and greeting to y’all,
Actually it is quite straightforward you just have to "ask the owner" about the length. I posted a small example on my blog have a look:
Europe, Middle East and Africa