Every now and then I come across an exception being thrown by the Flex framework. Often from ListBase code that renders itemRenderers and such. I'm looking for techniques to use to figure out even which of my ListBase instances is even throwing the error.
The difficulty arises when the top of the call stack originates in a callLaterDispatcher()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at mx.controls.listClasses::ListBase/addToFreeItemRenderers()
at mx.controls.listClasses::ListBase/reduceRows()
at mx.controls.listClasses::ListBase/updateDisplayList()
at mx.controls.listClasses::TileBase/updateDisplayList()
at mx.controls.listClasses::ListBase/validateDisplayList()
at mx.managers::LayoutManager/validateDisplayList()
at mx.managers::LayoutManager/doPhasedInstantiation()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.core::UIComponent/callLaterDispatcher2()
at mx.core::UIComponent/callLaterDispatcher()
In looking at a breakpoint in that I set in ListBase::addToFreeItemRenderers, I can see that the item is null that's being passed to the function, as so:
protected function addToFreeItemRenderers(item:IListItemRenderer):void
{
// The following item is NULL when the exception is being thrown...
if (item == null) return;
DisplayObject(item).visible = false;
var factory:IFactory = factoryMap[item];
...
How do I figure out what I need to figure out? I've solved similar issues before, but I had to use magic and voodoo and take guesses and throw in callLater calls in my code to fix.
Thanks