问题
I need to call a function located in the parent component and make the call from the child component in Flex 3. Is there a way to access functions in the parent component from the child component? I know I can dispatch an event in the child and add a listener in the parent to call the function, but just wanted to know if could also directly call a parent function from a child. Thanks
回答1:
You can use parentApplication
For example... if i have a main.mxml that calls a component we'll call child.mxml, i can call functions in main from within child by doing the following:
parentApplication.parentsFunctionName(parameters);
来源:https://stackoverflow.com/questions/3340516/is-it-possible-to-call-a-function-in-a-parent-component-from-a-child-component-i