Today seems to be 'one of those days'. Nothing is working
properly and I don't know if it's me or my machine. The code below
comes from the Adobe site-- it will not work for me unless I
comment out the event handler; this has been the story for all my
attempts to use an event handler with stage.
Here's my error message:
TypeError: Error #1009: Cannot access a property or method of
a null object reference.
at Demo/init()[C:\Documents and Settings\sxh12\My
Documents\Flex Builder 3\Demo\src\Demo.mxml:18]
Am I doing something wrong or is my Flex playing up?
It is a matter of timing: the stage is not immediately
initialized and available to you.
You can use a preloader to wait for the stage to catch up, or
as here, use the applicationComplete event instead.
Here is the trace results of the code below:
[SWF] C:\...\TestingStuff.swf - 556,906 bytes after
preInitialize - stage.addEventListener is NOT YET a Function!
initialize - stage.addEventListener is NOT YET a Function!
creationComplete - stage.addEventListener is NOT YET a
applicationComplete - stage.addEventListener is a Function.