> I tried using "public var userInput;" in the main.mxml but I could not > use this inside component.mxml because it got an error of undefined. Inside component.mxml, you could access this var as Application.application.userInput. However, Manish's suggestion of using an event is better. - Gordon
________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Manish Jethani Sent: Friday, February 01, 2008 12:43 AM To: [email protected] Subject: Re: [flexcomponents] Newbie component question... On 2/1/08, Daniel Poon <[EMAIL PROTECTED] <mailto:daniel.poon%40gmail.com> > wrote: > I learnt how to make a component in a separate file e.g. > component.mxml, but I am having problem with passing variables back to > the main.mxml. > > If I have a login TitleWindow for the component.mxml, once the user > input userID password, how do I pass this back to the main.mxml? [snip] This is one of the patterns I follow. <!-- component.mxml --> <TitleWindow> private function save() { data.userID = userIDTextInput.userID; data.password = passwordTextInput.password; } private function close() { PopUpManager.removePopUp(this); dispatchEvent(new Event(Event.CLOSE)); } </TitleWindow> >From your OK button you call save() and close(). The application handles the close event and gets the data from the data property of the component. Manish
