I have created a new component and moved a combobox from the main app to this component. In the main app I’ve include the component and it works marvelous. Also in the main app I have a label id="myLabel”. Now I want to change the text from myLabel when the combobox change (close event).
How can I allow e.g. the combobox in the new component to change something in the main app. It only works visaversa. (Of course I know that this is not the best practice, but I’m just wondering while testing)
In your component use:
this.parentApplication.myLabel.text = "Some Text";
If you want to access something that is not declared in mxml (ex: a property or a method) make sure it is public.
Technically this answer is correct, but for most scenarios it is wrong. You should not have your components change properties in their parent components, since this creates a tight coupling making re-use difficult or impossible.
The appropriate way to do this is to use events. A component emits an event and someone listens for this event and the text in the parent changes as a result of the event.