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.
Copy link to clipboard
Copied
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;