Viva! LiveDocs >> Regaining Scope from ItemRenderer in Flex 2

I am on some kind of streak with LiveDocs, where I’ve found answers to the last dozen or so hurdles I’ve encountered developing in Flex and AS3. I can’t recount them all, but my latest issue had to do with losing scope¬†with an inline component inside a dataGrid itemRenderer.

http://www.adobe.com/livedocs/flex/2/langref/mxml/component.html

Basically, I have to add icons in a few columns inside a dataGrid. These icons need to change based on each row’s data. That’s where the itemRenderer comes in. The challenge really came when I needed to add a click handler to the icon. Once inside the itemRenderer component, I was no longer able to call methods in the application code. LiveDocs (to the rescue) informs me that I need to make that method public and use “outerDocument” when I call that method. Needless to say, it worked.

Now that I’ve really lost the casual reader, let me continue my praise of LiveDocs¬†for providing me a detailed solution that somehow both kick ass Flex books (O’REILLY’s Programming Flex 2 and Wrox’s Professional Flex 2) seemed to gloss over. And now, back to the code.