1 person found this helpful
You can set the creationpolicy of the tab navigator to all that way child items are instantiated strait away instead of after tab selection.
Thanks for the reply.
I tried this. After login into the site, the first thing I do is use an httpService to download a large xml file. The file contains data for the datagrids, including paths to images and videos. The next thing I do is to create array collections that are used as dataProviders for the different datagrids.
The application mxml has components in this order login window, httpService, MainDividedBox. The MainDividedBox contains the TabNavigator with the datagrids. I only specify the creation policy for the TabNavigator, the other components including the main app, default to AUTO. I add a bunch of trace statements to the initialize and creationcomplete methods, so I can see what happens when the application starts.
The TabNavigator canvas/datagrids get initialized
Then an error
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.ameritest.renderers::VideoContainerItemRenderer/set data()......
The item renderer is looking for an image. The path is in the imagesArrayCollection created from the xml by the httpService. The code to generated the imagesArrayCollection is not called, until after a successful login, and we haven't even finished creating the application.
This is why I was trying to instantiate the datagrids after the login and the first tabs datagrid was displayed. While the user is looking at the first tab's datagrid, I want to start instantiating the next 4 tab's datagrids.
I am confused why the second tab's datagrid, which has an item renderer in the first column has a null data error. The first tab's datagrid and first in the MXML is not generating any null data errors.
It seems like the datagrids can be created without the data being available from the arrayCollections, but the item renderer needs the data. The error comes from the line of code that starts with "if"
public function set data(value:Object):void
_data = value;
if (_data.source != null && _data.representativeImage != null)
_imgSource = _data.representativeImage;
_videoSource = _data.source;
I removed the item renderer and the datagrids were created, but not populated yet.
The xml was then loaded.
The arraycollections created.
The datagrids then started populating themselves with data.
I waited a bit then clicked on the tabs. The datagids opened with data loaded and images displayed.
I had thought there was an issue with data, that really was an issue with accessing an object before it was created.