I am consistently encountering what I consider to be the most annoying error in Flex:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
I know that the reason I am getting this error is because the Child of the ViewStack has yet to be instantiated, so the value of that DisplayObject is null. Therefore I cannot call methods/set properties of that Child until I actually load it through navigation.
Is there some workaround to prevent this error from bugging me? I know creationPolicy is an option, but I would prefer not to have to instantiate all of the children at once.
I have a Login Form at the top of the page. When a Customer logs in the Store populates with items they have recently purchased.
I call the 'populate()' method of the Store page after the Login completes. However, the Store page may not necessarily have been instantiated yet because the User hasn't navigated to it yet. Therefore I cannot call that method.
If I go to the Store page before signing in, I don't get the error, but if I don't I will get the error.
I recommend model-view or MVC architectures. Each Viewstack child is a view that pulls its data from the model when it is created via data-binding.
Flex SDK Developer
Adobe Systems Inc.