thank you times a million though for your help
Printable View
thank you times a million though for your help
What I don't understand still though is, whilst my code works by only adding the keyEvent handlers once this has been added to the display list, if I call that same listener function (taking out the e:Event parameter) from the constructor function to get it to set up the keylisteners, it says that null message again. Surely it should have added it to the stage by 5 lines down the constructor function?
Nope. The item cannot be added until it is constructed, and it is not finished being constructed until the constructor returns. So the parent and stage will be null through the entire constructor.
Ahhhhh I seeeeeee. So if there's a function in the constructor function that says addEvent() and it goes off to do that, it hasn't completed constructing yet, so the parent and stage are null until it reads and processes the last line in the constructor function?
Correct. Actually even a little after that, since the execution stack has to be restored and the new object placed on the displaylist.
I didn't want to hijack the OP's thread so I started a new one:
http://board.flashkit.com/board/show...87#post4238887