View Full Version : Acccessing a function in another mxml file
dColumbus
09-27-2007, 08:33 PM
this is my layout:
1) Main.mxml - this contains a component.
2) Component2.mxml - this needs to reference the component id (and then a property of) that resides in Main.mxml.
I need access a property of a component from another component...
dColumbus
09-27-2007, 09:44 PM
this.parent or this.parentApplication.
drkstr
09-27-2007, 09:46 PM
3 Options in order from worst to best design practice.
1. Access any componetns in the main application with
Application.application.someComponent
2. Pass a reference of the component to Component2 by creating a public var in Component2
3. Don't reference the component in Component2 at all. Instead, dispatch an event from Component2 which is captured and acted upon in the Main.mxml. This allows for better OOP and portability since the Component2 isn't tightly coupled with the Main.mxml.
Best Regards,
...aaron
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.