I have an actionscript-instantiated component in a containment hierarchy; it extends ComboBox, but it’s instantiated dynamically–you never know when you’re going to need it.
Somewhere up in its containment hierarchy, there’s a thing which extends NavigatorContent which logically is the right place to put the valid values for said combo box.
What’s the canonical way for that child component to get a reference to that set of valid values?
I would solve this by having the child dispatch a bubbling event (CHILD_CREATED) with a self refrence when it’s created. Then simply listen for the CHILD_CREATED event in the object that has access to the set of valid values.
#1 Parent is created – add a listener to know when a child is created and needs a refrence to values
#2 Child is created – dispatches CHILD_CREATED dynamic event with a self refrence as a property
#3 Parent hears CHILD_CREATED – extracts the reference to the child component and sets its data provider to the set of valid values.
EDIT:
A much cleaner way to handle this kind of problem if you are dealing with a component based on DataGroup is to use the rendererAdd (there is a refrence to the renderer in the event). This would definitly be the canonical way to handle it.
So if you are using a DataGroup to display components that you need to access directly, just use the rendererAdd event. If that issn’t applicable to your problem, I’d go with the CHILD_CREATED method.