You can access your top-level application anywhere in your code via
Application.application.  To call the method named "myMethod," you
would use the statement Application.application.myMethod().

You can easily add event listeners on "sub-components" if you give the
components id's.  Taking your example of a button within another
component you could define it like so...

<!-- ExtendedPanel.mxml -->
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml";>
 <mx:Button id="myButton" />
</mx:Panel>

<!-- MyApp.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";>
  <ExtendedPanel id="ePanel"/>
</mx:Application>

and add an event listener within the the main application's script tag
with the statement:
ePanel.myButton.addEventListener(MouseEvent.CLICK,myClickHandler);

You could also have your ExtendedPanel catch the button's click event
and dispatch a custom event. Then you could do something like this:

ePanel.addEventListener(MyCustomEvent.BUTTON_CLICK,myClickHandler);

--- In [email protected], "Deniz Davutoglu"
<[EMAIL PROTECTED]> wrote:
>
> Hi everyone,
> I try to break apart my flex app and I get faced with one issue.
> I create components for every part of app and load them as I need. But
> it creates some problems.
> 
> First off all within component I cant call functions that are in main
> app mxml.
> Secondly I cant create events for sub component (for ex buttons) of my
> components.
> I dont want to create every component by by using action script. I
> want to use mxml. Did some one face this problem and create solution?
> 
> Thanks
> Deniz
>


Reply via email to