Skip to main content
Participant
October 25, 2020
Answered

how to pass variable value betewen timeline animate html5??

  • October 25, 2020
  • 1 reply
  • 512 views

HI. NEED YOUR HELP.

 

THE MOST SIMPLE, I HAVE A BUTTON TO JUMP TO THE NEXT FRAME (NEXT) AND I HAVE A DYNAMIC TEXT (SCORE).

 

THE CODE IN THE FIRST FRAME "index label" IS THIS

 

this.stop();
var _this = this;

this.next.on('click', function(){
	_this.gotoAndStop('pag1');
});

//I generated the variable "count" to later add

var count = 1;
this.score.text = count;

 

IN THE SECOND FRAME "pag1 label" I HAVE ONLY THIS

 

this.stop();

this.score.text = count;

I JUST WANT IT TO WORK AT CLIP LEVEL, AND ALREADY TRY USING THIS

 

 

this.count = 1;

 

BUT IT DOESN'T WORK, MAYBE IT'S BECAUSE I DO NOT KNOW WHERE TO PUT IT EXACTLY

 

WHAT SHOULD I PUT IN FRAME 1 SO THAT FRAME 2 STILL HAVE THE SAME VALUE?

    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    Hi.

     

    Firstly make the count variable a property of the main timeline by using the this keyword. Like this:

    this.stop();
    var _this = this;
    
    this.next.on('click', function(){
    	_this.gotoAndStop('pag1');
    });
    
    this.count = 1;
    this.score.text = this.count;

     

    Then, if you want to access the count property in another frame of the main timeline, you can do this:

    this.stop();
    this.score.text = this.count;

     

    But, if you want to access the count property from within a Movie Clip or somewhere else, use the automatically generated global variable exportRoot.

    this.stop();
    this.score.text = exportRoot.count;

     

    Please let us know if you still have any questions.

     

    Regards,

    JC

    1 reply

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    October 26, 2020

    Hi.

     

    Firstly make the count variable a property of the main timeline by using the this keyword. Like this:

    this.stop();
    var _this = this;
    
    this.next.on('click', function(){
    	_this.gotoAndStop('pag1');
    });
    
    this.count = 1;
    this.score.text = this.count;

     

    Then, if you want to access the count property in another frame of the main timeline, you can do this:

    this.stop();
    this.score.text = this.count;

     

    But, if you want to access the count property from within a Movie Clip or somewhere else, use the automatically generated global variable exportRoot.

    this.stop();
    this.score.text = exportRoot.count;

     

    Please let us know if you still have any questions.

     

    Regards,

    JC

    Participant
    October 26, 2020

    Thank you, it already works, but in the second frame change the instance name of the dynamic text : score by score 1