3
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 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 I press the start button, it works normally, as it was programmed, and it doesn’t show any kind of error on the console.
my problem is the game insists on showing me the Error #1009
AFTER THE FIRST EXECUTION!
It is worth noting that when the person loses in the game, he gets two buttons: One allows him a quick restart to the game (back to frame 1 of the scene), and another takes back to the main menu, if the person returns to the game immediately, it works smoothly again. This bug only happens when the person loses, goes back to the menu, and only then plays again!
To understand what was causing the problem, I allowed debugging, and the result:
I went to check the code on line 2 and realized it’s nothing more than confirmation that the player still has lives:
It is worth mentioning the variable lives
on the main Timeline:
I imagine that because it is a test of the value of the variable int
, should not be understood as an object by AS3, let alone a null object, but I’m new to AS3, so I’m not sure about that!
EDIT: Following Lucas Nunes' tip, I added:
Upshot:
How should I proceed with this Movieclip(root) when it becomes null??
Was it not the conversion of
MovieClip(root)
which failed? Check whetherMovieClip(root) != null
before the rest ofcontrolShield()
for us to see...– Lucas Lima
It really was Movieclip(root) that failed! How should I proceed??
– Gammeth