Copy link to clipboard
Copied
I have this line in an expression on one layer (say "LayerA"):
randNum=Math.round(random(0,4))+effect("Color Offset")("Slider");
Is there a way i can use 'randNum' from LayerA as the SourceText for a separate text layer (layerB)?
You have a completely wrong understanding how expressions in AE work. There is no such think as global variables and the return value is always the absolute value of the property stream, nothing more, regardless whether it's generated by keyframes, expressions or a combination of one on top of the other. If the code is part of a larger construct, then you need to post the code in its entirety. Otherwise nothing stops you from generating the random values on a separate expression control if it ne
...Copy link to clipboard
Copied
Simply pickwhip the expression to the source text.
Mylenium
Copy link to clipboard
Copied
Hey Mylenium -
I tried pickwhipping to the line defining randNumber, but that doesn't work.
And my problem is randNumber is not the final output of LayerA - it's simply used in a larger chunk of code.
I was hoping to link to some variables and show them on screen as text so I could try to debug the code and figure out where things are going wrong. Wasn't sure if I needed to use Return to make the variable available to other layers, or make it a Global as opposed to Local variable, or do anything with numbers to text. If any of those would work, i was hoping someone could show me the syntax to use in After Effects. From what I've read online, I'm not sure that After Effects lets you directly access another layer's variable - so was just trying to get some clarification.
Copy link to clipboard
Copied
You have a completely wrong understanding how expressions in AE work. There is no such think as global variables and the return value is always the absolute value of the property stream, nothing more, regardless whether it's generated by keyframes, expressions or a combination of one on top of the other. If the code is part of a larger construct, then you need to post the code in its entirety. Otherwise nothing stops you from generating the random values on a separate expression control if it needs to be re-used by multiple other expressions. Again, you simply have things backwards.
Mylenium
Copy link to clipboard
Copied
You're certainly right that my knowledge of expressions in AE is rudimentary. I've learned just enough javascript / actionscript / and PHP in the past to be dangerous - remembering bits and pieces of how things work and able to slog through other people's code to get the gist of how things work. Going to read through some of the After Effect manual on expressions go through some more tutorials and sites to get a better background. (didn't want to post the whole code block, because it came from a tutorial and I didn't want to post someone else's material)
Thanks for your help (and info on global variables and how 'return value' works in AFX expressions)
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more