Skip to main content
Participant
June 3, 2013
Question

How to do a AS3 Score Counter with multiple Scenes

  • June 3, 2013
  • 1 reply
  • 1940 views

I've created an online quiz that tells you how many days you'll last if cats take over the world.  If you want to try it, here's the link:

http://www.curtisjenkinsportfolio.com/Cat%20Take%20Over.html

However, I can't get the action script to properly count up the number of days you'll last.  I've found plenty of advice for creating a counter, but they always reset at the end of the scene.  Since each question is it's own scene, I need the counter to continue throughout the entire project.  Can anyone help?

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
June 3, 2013

if you create a variable that's not a reference to an on-stage object, it will not reset when scenes change.

Participant
June 3, 2013

Wow, that brought me down a rabbit hole.  Now I'm having a really hard time creating any kind of counter without having to know quite a bit of coding.  Any ideas?

kglad
Community Expert
Community Expert
June 3, 2013

// execute once to create your counter and initialize its value.

var counter:int = 0;

//everytime you want to increment your counter, use:

counter++;

//everytime you want to decrement your counter, use:

counter--;