|
-
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.
-
 Originally Posted by 5TonsOfFlax
Correct. Actually even a little after that, since the execution stack has to be restored and the new object placed on the displaylist.
Thank you. That's a valuable bit of knowledge I have gained through the last 4 hours of nothing to show for work! That's great, it will no doubt help me structure things better and avoid future similar problems.
-
 Originally Posted by 5TonsOfFlax
Could you give an example of some non-keyboard event that you'd want to listen for at the stage level?
I didn't want to hijack the OP's thread so I started a new one:
http://board.flashkit.com/board/show...87#post4238887
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|