You can't put the expression on a null object, but you can use a text layer.
eval() tip I tried using the source text of a text layer and running
eval() on it. Initially I had no success, I was getting an "object of type TextProperty found where a Number, Array or Property is needed" error. But if I put something like a number on its own in the text layer and treated the source text like an array I could get it, I just wasn't able to access a whole string.
So after a bit of fiddling around with quotes and escaping (neither are needed, thank heavens) I got it to work.
TL;DR: Here is how you reference an expression that is written in a text layer's source, without having to save external files:
var theExpression = thisComp.layer("your text layer").text.sourceText.value;
And then you write the expression into the text layer, in this case called "your text layer". This is really cool! It even updates in real time as you're typing the expression!
Here's a comp with the position of the cyan layers being driven by the expression you see on the text layer. If I duplicate one of the cyan layers its position is calculated individually based on the random seed
index, and if I change the expression, they all update!
I'm stoked, this was the best question ever!
value property which represents the raw value of the AE property. And the value of the AE source text property is an object which must include formatting and whatnot, and so it is different to the text.sourceText.value value. Confused?