Page 1 of 1

Has anyone found a practical use for the $.global object?

Posted: April 29th, 2019, 10:51 pm
by pablohotsauce
A few weeks ago, I messed around with trying to create global variables in Expressions. I remember adding some code similar to this to a text layer's Source Text property:
$.global.myVar1 = "hello world";

And then in another text layer's Source Text prop, I called that var:
$.global.myVar1;

And that second text layer actually displayed "hello world" in the viewport! But if I reordered the layers, or tried reassigning myVar1's value in the second text layer, all sorts of buggy things would happen. I tried recreating the setup just now, but it won't work at all, and I don't remember what exactly I did the first time. But I do remember it working.

So, has anyone found any useful and predictable behavior for $.global?

Re: Has anyone found a practical use for the $.global object?

Posted: May 7th, 2019, 4:44 pm
by zlovatt
Any sort of shared space is incidental, buggy, and shouldn't be relied upon. Don't do this.

Re: Has anyone found a practical use for the $.global object?

Posted: May 11th, 2019, 2:31 am
by pablohotsauce
But I wanna break stuff :(

I figured it probably wasn't useful, but now I'm frustrated that I can't remember what code I used to get a buggy global variable working, a while back. Either the code in my original post is wrong, or it did actually work in 16.0.1, but that behavior got patched out in 16.1.1.