0

I was thinking if I could pass a value from a variable when I go to a next scene. Like for example, I have Scene 1 and Scene 2. In scene 1, I'm playing a game and ofc, I am having a score. When the character in the game dies, it will go to the second scene. The method I used in going to the second scene is gotoAndStop. How can I pass the score to the second scene so I could show it in the Game over scene(scene2)? Thanks! :))

Gibs
  • 109
  • 1
  • 4
  • 12

2 Answers2

0

Use a global variable or use the singleton pathern. See this answer global variables in AS3

Community
  • 1
  • 1
simion314
  • 1,394
  • 16
  • 29
0

You could define a class to store your score.

package file_as {//this is the package name

    public class CScore {

        public function CScore() {
            public var MyScore:int = 100;
        }

    }

}

And in the script,you just new it and use it.Like,trace("CScore.MyScore");