I often find myself investigating code issues from other programmers. Recently I had to deal with a rather complicated Flex 3 container problem. The problem occurred when resizing an application. The runtime error was
TypeError: Error #1009: Cannot access a property or method of a null object reference. at mx.controls.listClasses::ListBase/addToFreeItemRenderers()[E:\dev\3.1.0\frameworks\projects\framework\src\mx\controls\listClasses\ListBase.as:4770] at mx.controls.listClasses::ListBase/reduceRows()[E:\dev\3.1.0\frameworks\projects\framework\src\mx\controls\listClasses\ListBase.as:3863] at mx.controls.listClasses::ListBase/updateDisplayList()[E:\dev\3.1.0\frameworks\projects\framework\src\mx\controls\listClasses\ListBase.as:3639] at mx.controls.listClasses::TileBase/updateDisplayList()[E:\dev\3.1.0\frameworks\projects\framework\src\mx\controls\listClasses\TileBase.as:2357] at mx.controls.listClasses::ListBase/validateDisplayList()[E:\dev\3.1.0\frameworks\projects\framework\src\mx\controls\listClasses\ListBase.as:3279] at mx.managers::LayoutManager/validateDisplayList()[E:\dev\3.1.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:605] at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\3.1.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:678] at Function/http://adobe.com/AS3/2006/builtin::apply() at mx.core::UIComponent/callLaterDispatcher2()[E:\dev\3.1.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8565] at mx.core::UIComponent/callLaterDispatcher()[E:\dev\3.1.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8508]
Trying to reproduce the problem was more problematic. First it is all Adobe Flex code in the call stack.
Second the error would not occur unless you went through a set of steps. First you needed to have enough items in the tile list where to cause vertical scrolling. Then you needed to load a different list of items into tile list that did not require a vertical scroll. After that you resized the application to smaller you get the above error.
The code referenced in the above call stack is Adobe Flex code and the signature of the offending method to the offending line is shown here:
protected function addToFreeItemRenderers(item:IListItemRenderer):void { // trace("addToFreeItemRenderers ", item); DisplayObject(item).visible = false;
The error is caused by the item variable having a null value.
The solution we used was found at Tom Van den Eynde RIA Flex Blog entry Exception after TileList resize.
Adding a resize event to the TileList in the complex embedded containers and calling executeBindings() on the TileList object made the problem go away.