Understanding Flex itemRenderers – Part 3: Communication
In Part 2 of this series, I showed you how to make external itemRenderers in both MXML and ActionScript. In the examples I've been using, there is a Button which dispatches a custom event—BuyBookEvent—so the application can react to it. This article covers communication with itemRenderers in more detail.
There is a rule I firmly believe must never be violated: you should not get hold of an instance of an itemRenderer and change it (setting public properties) or call its public methods. This, to me, is a big no-no. The itemRenderers are hard to get at for a reason, which I talked about in Part 1: the itemRenderers are recycled. Grabbing one breaks the Flex framework.
With that rule in mind, here are things you can do with an itemRenderer:
- An itemRenderer can dispatch events via its list owner. (You've seen bubbling; this is a better practice, which you'll see below.)
- An itemRenderer can use static class members. This includes Application.application. If you have values stored "globally" on your application object, you can reach them that way.
- An itemRenderer can use public members of the list that owns it. You'll see this below.
- An itemRenderer can use anything in the data record. You might, for example, have an item in a record that's not for direct display, but which influences how an itemRenderer behaves.
This series includes the following articles:
Requirements
In order to make the most of this article, you need the following software and files:
Flex Builder 3
Prerequisites
To benefit most from this article, it is best if you are familiar with Flex Builder and ActionScript 3.0.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
About the author
Peter Ent is a Computer Scientist at Adobe, working on the Genesis project. Prior to this, Peter worked for Adobe Customer Care as a Flex Support Engineer and then as a Technical Account Manager. Before joining Adobe, Peter worked in the financial services industry at State Street and Fidelity Investments. He also has experience at two start-ups building software applications doing imaging and molecular modeling. Peter holds a bachelor of science in Computer Science from Syracuse University. Visit Peter's blog.