Copy link to clipboard
Copied
Hi, I have a simple 2-item array (an x/y point position) and I want to change the value of the first item, but I'm getting an "Error: cannot assign value" on the line that attempts to change that value. Can anyone tell me what's going wrong? Here's my code:
xyPos = effect("Down Position")("Point");
if (thisComp.layer("Control").effect("Center Letter")("Checkbox") > 0){
xyPos[0] = xyPos[0]+88;
}
xyPos
Thanks!
1 Correct answer
I think it will work if you change your first line to this:
xyPos = effect("Down Position")("Point").value;
Copy link to clipboard
Copied
Note: I've tried the following command instead:
xyPos[0] = 88
...and it still gives the same error.
Copy link to clipboard
Copied
Booleans are explicit, so you can do a proper true/ false check and of course all the rest like not returning a full array to AE or providing a fallback when the condition isn't met. This should work:
Ref = effect("Down Position")("Point");
Switch=thisComp.layer("Control").effect("Center Letter")("Checkbox");
if (xySwitch != 0){
xPos = Ref[0]+88;
}
else{
xPos=Ref[0]:
}
[xPos,Ref[1]]
Mylenium
Copy link to clipboard
Copied
I think it will work if you change your first line to this:
xyPos = effect("Down Position")("Point").value;
Copy link to clipboard
Copied
This worked perfectly. Can you explain to me why? Why is the ".value" needed?
Thanks!
Copy link to clipboard
Copied
effect("Down Position")("Point") is an object representing the Point Control. Sometimes you can get away with referencing an object like that and the expression engine will figure out that you really wanted to use the value of that object, but not always. Sometimes you have to tell it explicitly with .value. So you can either just always stick .value in there when referencing expression controls, or do it when that error pops up.

