how can i pass values from my custom components back to the main.mxml? i need to do this to pass back ana array collection
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can call directly into Application using the static Application.application.yourPublicMethodName() or .yourPublicPropertyName = n, but you might also consider using the event framework, to keep your components loosely coupled. Since your component is by definition an event dispatcher, you can simply dispatch an event from within it, and have your Application class listen for that event.
In MXML, that looks something like this, for the component class:
… and for the Application, like this:
The Event metadata tag in the component class tells the compiler the component dispatches a flash.events.Event-type event (‘buttonClicked’), which exposes it as an event on the MyComponent tag; then, all you need to do is wire up a listener for that event, and through the event’s currentTarget property, you get access to all of the component’s public data.
Just figured I’d offer up an interesting alternative for ya. Hope it helps!