I’m starting to give up on the Flex forums so I’l re-post here and see how things go. Long time lurker, first time poster 😉
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
(creating answer so this question could be marked as answered)
Usually, when reference to component is null and it should not, this means component isn’t created yet. This might have place before application
initializeevent or if component’s parent isn’t visible and not validated.