By the way, why are you wrapping your <Login> and <Register> components inside <Canvas>es to put them into the <ViewStack>? This probably isn't necessary. The children of a ViewStack must be some kind of Container, and I'm guessing that Login and Register are subclasses of Container.
Gordon Smith Adobe Flex SDK Team ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Gordon Smith Sent: Wednesday, April 16, 2008 2:43 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Re: Flex Compenents, how to make them talk A click handler in Login's <Script> could do Application.application.vsApp.selectedChild = Application.application.vsRegister; but it wouldn't be good practice because it means that Login has too much knowledge about Application. If you don't want to use events, put public function showRegister() { vsApp.selectedChild = vsRegister; } in Application's <Script> and have your click handler in Login's <Script> call it: Application.application.showRegister(); or parentDocument.showRegister(); That way, Login asks Application to do something without telling it how to do it. Gordon Smith Adobe Flex SDK Team ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of timgerr Sent: Wednesday, April 16, 2008 2:23 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Flex Compenents, how to make them talk Lets say I have a Flex Component called test1.mxml and that component has a view stack. I then create another component called test2.mxml and I want to reference the view stack in test1.mxml, can I do that? The problem is I want to change states so I have a component that is register.mxml and another one that says login.mxml. So here I have a veiwStack on the main application for <Application xmlns:log="com.login.*" mxlns:reg="com.register.*"> <mx:ViewStack id="vsApp" width="100%" height="100%"> <mx:Canvas label="vsScreenLogin" id="vsScreenLogin"> <log:Login x="302" y="138"/> </mx:Canvas> <mx:Canvas label="vsRegister" id="vsRegister"> <reg:Register/> </mx:Canvas> </mx:ViewStack> </Application> OK, so in the login.mxml I have a button that says register and when that is clicked I want to run this to change the state: vsApp.selectedChild=vsScreenLogin. I am unable to run this command from Login.mxml because login.mxml dosnt know about the main app. How can I pass information from a Flex component to the main application???? Thanks for the help, timgerr --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , "Gordon Smith" <[EMAIL PROTECTED]> wrote: > > If you have > > > > <Application> > > <MyContainer id="myContainer"> > > <MyControl id="myControl"/> > > </myContainer> > > </Application> > > > > then in the Application's <Script> you can simply refer to the > MyContainer instance as myContainer and to the MyControl instance as > myControl (NOT myContainer.myControl). > > > > In MyContainer's <Script> you can refer to the Application instance as > parentDocument or as Application.application. > > > > In MyControls' <Script> you can refer to to the MyContainer instance as > parentDocument and to the Application instance as > parentDocument.parentDocument or as Application.application. > > > > In general, you can access anything from anywhere. > > > > Gordon Smith > > Adobe Flex SDK Team > > > > ________________________________ > > From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> ] On > Behalf Of timgerr > Sent: Tuesday, April 15, 2008 8:20 PM > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> > Subject: [flexcoders] Flex Compenents, how to make them talk > > > > I was wondering if I create a Flex Application and have 5 Flex > components that integrate within my Flex App, how can they all talk to > each other???? Since they do not know about each other till the swf > file is compiled, I am unable to have one component event trigger > something on another component because they dont know about each other. > > Thanks for the help, > > Timgerr >