I'm a beginner in AS3, and I'm building a game for a course I'm doing.
As I want the game to be very well done, I decided to create a game with menu, where you can access the basic preferences (Turn off music, instructions, etc.)
And when I open the game, and press the button to start, it works normally, as it was programmed, and does not show any type of error in the console.
My problem is the game insists on showing me Error #1009
AFTER the first run!
It is worth mentioning that when the person loses in the game, it receives two buttons: One allows a quick restart to the game (returning to frame 1 of the scene), and another takes you back to the main menu, if the person returns to the game immediately, it works without problems again. This bug only happens when the person loses, returns to the menu, and then returns to play!
To understand what was causing the problem, I allowed debugging, and the result:
Icheckedthecodeonline2andrealizedthatitisnothingmorethanconfirmationthattheplayerstillhaslives:
It's worth highlighting the variable lives
in the main timeline:
Ithinkthatsinceitisatestofthevalueofint
,itshouldnotbeunderstoodasanobjectbyAS3,letaloneanullobject,butIamnewtoAS3,soI'mnotsure!>
EDIT:FollowingthetipofLucasNunes,Iadded:
Result:
How do I proceed with this MovieClip (root) when it becomes null ??