Null reference and gotoAndStop() bugs


Sometimes, after I restart Wick (either by doing a hard refresh, reopening the same document, or restarting my browser), I get an error that I didn’t get the last time I ran the project. In this case, I got Menu.animation is not defined.

Menu is a clip with multiple frames, and only one of them, correct, has a Clip on it called animation. I think what happened was…

  1. While testing my project, I opened the frame of Menu that contained animation. This is because I had some code that ran Menu.gotoAndStop("correct"); This set the value of Menu.animation.
  2. I added some code directed at animation.
Menu.animation.gotoAndPlay(0); //NEW CODE
  1. I kept testing the project. The new function seemed to silently fail without throwing an error. I suspect this is because the new code runs BEFORE gotoAndStop(), which leads to a null reference; I haven’t jumped to the frame with animation on it yet. (I think this is an undesirable behavior; gotoAndStop should run first.)
    The function failed silently because Menu.animation was technically set – it was just set to an outdated value that was still in memory.
  2. I did a hard refresh, since things seemed funny. (I had already bumped into a similar bug.)
  3. I tested the project again, and got an error: Menu.animation is not defined

I’m not exactly sure if this theory is correct, but I gotta go finish game jam stuff so I can’t investigate it right now. Hope this helps!


Post-Jam Feedback: Misc. Bugs

I think that always running the project in a sandboxed environment (i.e. clearing all variables and data when you press Pause) would help resolve both this issue and this one.