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

Moderators: Disciple, zlovatt

Post Reply
User avatar
pablohotsauce
Posts: 3
Joined: April 13th, 2019, 2:19 pm

April 29th, 2019, 10:51 pm

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?
User avatar
zlovatt
Posts: 33
Joined: October 31st, 2016, 5:00 pm
Location: Los Angeles
Contact:

May 7th, 2019, 4:44 pm

Any sort of shared space is incidental, buggy, and shouldn't be relied upon. Don't do this.
User avatar
pablohotsauce
Posts: 3
Joined: April 13th, 2019, 2:19 pm

May 11th, 2019, 2:31 am

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.
Post Reply