Hi I am having trouble in my Flex 2 application in terms of calling a function of a component from another component etc….
I have in my main MXML file an “ApplicationControlBar” containing a “LinkBar” that is populated by a “ViewStack” as shown:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comps="components.*" layout="vertical">
<mx:ApplicationControlBar id="acb" dock="true">
<mx:LinkBar id="menu_lb" dataProvider="menu_vs"/>
</mx:ApplicationControlBar>
<mx:ViewStack id="menu_vs" resizeToContent="true" width="100%">
<comps:homePage id="home_page" label="Home Page"/>
<comps:menu1 id="menu_1" label="Menu 1"/>
<comps:menu2 id="menu_2" label="Menu 2"/>
<comps:menu3 id="menu_3" label="Menu 3"/>
</mx:ViewStack>
</mx:Application>
I want to have a Button that is within the “homepage” component which when is “clicked” calls a function (testFunc() etc) that is in the “menu1” component…
If the button was within the main MXML application file (as shown above) I could add the button which works fine and how is expected:
<mx:Button label=”go to menu1” click=”menu_1.testFunc()”/>
Although if I put this button in the “homePage” component then I get the error:
1120: Access of undefined property menu_1
as it is not defined within this component etc….
is there a way of communicating to the route application file to get this to work… e.g. I have tried things such as:
click=”parentDocument.menu_vs.menu_1.testFunc()” etc…….
but have had no joy
Can anyone tell me how to get my button click to navigate to / run the testFunc() within a different component in the viewStack……
Thanks,
Jon.