Use a variable from another symbol HTML5

New Here ,
Oct 21, 2020 Oct 21, 2020

Copy link to clipboard

Copied

How to do to be able to use a variable that is inside a symbol in another symbol?
What I want to do is count points in a symbol, when changing symbols I want it to keep the same score.

var count = 0;
this.total.text = count;

keep that value and use it in the next symbol.


Views

48

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Oct 21, 2020 Oct 21, 2020

Copy link to clipboard

Copied

LATEST

It's (usually) impossible to externally access variables declared with var in a symbol's code, because they cease to exist after the code finishes executing. To make a variable persistent and externally accessible, you have to make it a property of the symbol:

this.count = 0;

 

But this is probably the wrong approach anyway. It sounds like it would be more appropriate to just make the count globally accessible by storing it on the root object, exportRoot:

exportRoot.count = 0;

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines