{"id":36,"date":"2008-09-19T12:08:36","date_gmt":"2008-09-19T17:08:36","guid":{"rendered":"http:\/\/www.lonhosford.com\/lonblog\/2008\/09\/19\/flex-tilelist-listbase-fails-on-resize\/"},"modified":"2014-03-16T12:52:25","modified_gmt":"2014-03-16T17:52:25","slug":"flex-tilelist-listbase-fails-on-resize","status":"publish","type":"post","link":"https:\/\/www.lonhosford.com\/lonblog\/2008\/09\/19\/flex-tilelist-listbase-fails-on-resize\/","title":{"rendered":"Flex Tilelist Listbase Fails on Resize"},"content":{"rendered":"<p>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<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\r\nTypeError: Error #1009: Cannot access a property or method of a null object reference.\r\nat mx.controls.listClasses::ListBase\/addToFreeItemRenderers()&#x5B;E:\\dev\\3.1.0\\frameworks\\projects\\framework\\src\\mx\\controls\\listClasses\\ListBase.as:4770]\r\nat mx.controls.listClasses::ListBase\/reduceRows()&#x5B;E:\\dev\\3.1.0\\frameworks\\projects\\framework\\src\\mx\\controls\\listClasses\\ListBase.as:3863]\r\nat mx.controls.listClasses::ListBase\/updateDisplayList()&#x5B;E:\\dev\\3.1.0\\frameworks\\projects\\framework\\src\\mx\\controls\\listClasses\\ListBase.as:3639]\r\nat mx.controls.listClasses::TileBase\/updateDisplayList()&#x5B;E:\\dev\\3.1.0\\frameworks\\projects\\framework\\src\\mx\\controls\\listClasses\\TileBase.as:2357]\r\nat mx.controls.listClasses::ListBase\/validateDisplayList()&#x5B;E:\\dev\\3.1.0\\frameworks\\projects\\framework\\src\\mx\\controls\\listClasses\\ListBase.as:3279]\r\nat mx.managers::LayoutManager\/validateDisplayList()&#x5B;E:\\dev\\3.1.0\\frameworks\\projects\\framework\\src\\mx\\managers\\LayoutManager.as:605]\r\nat mx.managers::LayoutManager\/doPhasedInstantiation()&#x5B;E:\\dev\\3.1.0\\frameworks\\projects\\framework\\src\\mx\\managers\\LayoutManager.as:678]\r\nat Function\/http:\/\/adobe.com\/AS3\/2006\/builtin::apply()\r\nat mx.core::UIComponent\/callLaterDispatcher2()&#x5B;E:\\dev\\3.1.0\\frameworks\\projects\\framework\\src\\mx\\core\\UIComponent.as:8565]\r\nat mx.core::UIComponent\/callLaterDispatcher()&#x5B;E:\\dev\\3.1.0\\frameworks\\projects\\framework\\src\\mx\\core\\UIComponent.as:8508]\r\n<\/pre>\n<p>Trying to reproduce the problem was more problematic. First it is all Adobe Flex code in the call stack.<\/p>\n<p>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.<\/p>\n<p>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:<\/p>\n<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\n\r\nprotected function addToFreeItemRenderers(item:IListItemRenderer):void\r\n{\r\n   \/\/ trace(&quot;addToFreeItemRenderers &quot;, item);\r\n\r\n   DisplayObject(item).visible = false;\r\n\r\n<\/pre>\n<p>The error is caused by the item variable having a null value.<\/p>\n<p>The solution we used was found at Tom Van den Eynde RIA Flex Blog entry <a href=\"http:\/\/riaflex.blogspot.com\/2007\/06\/exception-after-tilelist-resize.html\" target=\"_blank\">Exception after TileList resize<\/a>.<\/p>\n<p>Adding a resize event to the TileList in the complex embedded containers and calling executeBindings() on the TileList object made the problem go away.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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()&#x5B;E:\\dev\\3.1.0\\frameworks\\projects\\framework\\src\\mx\\controls\\listClasses\\ListBase.as:4770] at mx.controls.listClasses::ListBase\/reduceRows()&#x5B;E:\\dev\\3.1.0\\frameworks\\projects\\framework\\src\\mx\\controls\\listClasses\\ListBase.as:3863] at mx.controls.listClasses::ListBase\/updateDisplayList()&#x5B;E:\\dev\\3.1.0\\frameworks\\projects\\framework\\src\\mx\\controls\\listClasses\\ListBase.as:3639] at [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[9],"class_list":["post-36","post","type-post","status-publish","format-standard","hentry","category-general","tag-flex"],"_links":{"self":[{"href":"https:\/\/www.lonhosford.com\/lonblog\/wp-json\/wp\/v2\/posts\/36","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lonhosford.com\/lonblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lonhosford.com\/lonblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lonhosford.com\/lonblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lonhosford.com\/lonblog\/wp-json\/wp\/v2\/comments?post=36"}],"version-history":[{"count":5,"href":"https:\/\/www.lonhosford.com\/lonblog\/wp-json\/wp\/v2\/posts\/36\/revisions"}],"predecessor-version":[{"id":3315,"href":"https:\/\/www.lonhosford.com\/lonblog\/wp-json\/wp\/v2\/posts\/36\/revisions\/3315"}],"wp:attachment":[{"href":"https:\/\/www.lonhosford.com\/lonblog\/wp-json\/wp\/v2\/media?parent=36"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lonhosford.com\/lonblog\/wp-json\/wp\/v2\/categories?post=36"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lonhosford.com\/lonblog\/wp-json\/wp\/v2\/tags?post=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}