This content has been marked as final. Show 6 replies
Try to boil this down to simplified sample code that gives the error, and please post with minimal sample data, then it will be easy to solve.
The easiest way around this is to bind labelField and dataProvider to a variable or getter/setter and then set the variables (or setter) in the result handler.
What's happening is that the combo box hasn't been instantiated at the point at which you're trying to set the values, hence the null pointer.
Thank you, binding to a variable and then setting the variable in the dataServiceResult method works perfectly. This brings up another question, however -- suppose I do need to manipulate the combo box directly (or any other control) -- is there specific event I need to wait for before I can safely access the control? For instance, I was considering using this event to dynamically create a bunch of checkboxes based on data returned from the HTTPService and add them to a VBox, but it probably won't work because the VBox will be null during this event.
The parent container's creationComplete event fires when all the children are instantiated.
For your data-driven check boxes, consider Repeater. It will save you lots of code, and has other benefits as well.
If you create a data-driven component or display, use a dataProvider, and have your check boxes update that on change. This is much better than trying to maintain references to the check boxe instances and trying to get their selected values. Though that can be done, especially easily with Repeater. But data access through the dataProvider is the Flex "way".
I took your advice and used the Repeater control, bound to my xml via the dataProvider property. It is exactly what I was looking for -- thank you very much!
How do you bind a labelField and dataProvider to a variable or getter/setter. I Know this maybe a newb question but I get this null object reference all the time.
Thanks in advance