Skip navigation
Currently Being Moderated

Custom component scope & events

Apr 15, 2012 9:44 AM

Tags: #scope #events

I'm trapping keyboard events on the stage and dispatching custom events through a framework (Mate, though I don't know that this is an important issue), but I'm pretty confused by the scope. The structure is:

 

  --application (traps keyboard events and dispatches custom event

 

            ----  mainPanel (receives dispatched events but mainCalendar (a child element) is null

                             on debugging. Obviously if I try to call a public method on mainCalendar

                             it errors out, even though it's a child of mainPanel. However, mainCalendar is

                             NOT null IF I use FlexGlobals.topLevelApplication.mainPanel.mainCalendar.

                             Outerdocument and parentDocument do not expose mainCalendar either, BTW

 

                      ----  mainCalendar (a custom component inside mainPanel with public methods. Creation policy is 'all' and it's visible and exists long before I trap any keystrokes at the top level)

 

 

Could someone take a minute and explain why the mainCalendar is out of scope when mainPanel receives a custom event, even though mainCalendar is a child of mainPanel. Is there a better way to manage the events so I don't have to always address the component via the topLevelApplication?

 

Thanks

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points