Skip navigation
cheftmo
Currently Being Moderated

Passing additional data to an ItemRenderer

Feb 16, 2012 4:29 PM

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.

 

Thx,

 

Carlos

 
Replies
  • Currently Being Moderated
    Feb 17, 2012 11:38 AM   in reply to cheftmo

    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

     

    set data(value:Object):

    {

         currentState = ThatClass.StaticPublicVarialbeOfThisClass  == 10 ? "10state":"noneState";

    .

    .

    .

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 9, 2012 11:03 AM   in reply to cheftmo

    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:

    http://blog.claudiu-ursica.ro/2012/03/08/updating-an-itemrenderer-styl e-or-state-based-on-the-parent-list-based-controls-number-of-items/

     

    C

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points