Accessing items created by a Repeater

So, I’ve got some components that will need to be updated by non-programmers, so in the interest of keeping things easy to understand for them, I’m using Repeaters when I need to create multiple items based on Data (rather than creating my own component that creates these items itself through the data, which would be much more efficient, and less vexing).

So, using Repeaters creates many issues you don’t usually come in contact with. Here are some of the things I’ve run into, and the workarounds.

  • Repeater.currentItem not available in the click handler
    • Same as with a list and an ItemRenderer, but because I just need a button, and nothing fancy, this is annoying. I got around this by setting the “data” property (FB won’t suggest data as a property, but it’s there!) to Repeater.currentItem.
  • Repeater isn’t on the display list, and doesn’t have an array of ‘children’, so it’s hard to get at the items that were created.
    • A mysterious feature of Repeaters is that if you set the id of the items created, AS3 will see an array based on that ID
      This means that if I use <Button id=”buttonArray” /> I will be able to do a “for each(b:Button in buttonArray)” loop to get access to those buttons. This works just like the groupName property of RadioButtons.
  • Button property ’selectedField’ only gets the state, and does not set the data’s value when ’selected’ is changed.
    • I’m not sure how I feel about this. Part of me expects that when the button changes to ’selected’, the data’s field should be changed too. Then the pedantic, MVC Loving part of me kicks in and wants to strangle anyone who lets the interface directly change the model… so I end up half-strangled and completely exhausted.

0 comments ↓

There are no comments yet...Kick things off by filling out the form below.

You must log in to post a comment.