Skip to main content
bogdanc5777499
Participant
February 11, 2018
Question

add to counter when reaching a certain frame

  • February 11, 2018
  • 1 reply
  • 236 views

So I have a project where I control which frame I go to by moving my mouse around. I also have a counter which I want to increase when I reach a certain frame.

Here's the code on the first frame for the counter.

       

        var Count:Number = 0;

        stage.addEventListener(Event.ENTER_FRAME,enterEachFrame);

        function enterEachFrame(e:Event):void

        {

   

        if (Counter_txt.text >= (8).toString())

                {

                        gotoAndStop(1,"Scene 7");

                }

        }  

And here's the code I've been trying to put at the frames to add to the counter, this is where I'm running into the problem.

    trace("3");

            Count = Count + 1;

            Counter_txt.text = (Count).toString();

    }

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
February 11, 2018

the problem's in frame 1.

use:

user

        var Count:Number = 0;

        stage.addEventListener(Event.ENTER_FRAME,enterEachFrame);

        function enterEachFrame(e:Event):void

        {

   

        if (Counter>= 8)

                {

                        gotoAndStop(1,"Scene 7");

                }

        }