Activity › Forums › Adobe After Effects Expressions › Expression – Works ?
-
Expression – Works ?
Posted by Christopher Rotter on August 19, 2010 at 6:17 amCould someone tell me if there is anything wrong with this expression because After Effects CS3 fires back an error and if there isn’t anything wrong with the expression this then I’m upgrading to CS4, this has been driving me bonkers the last few days.
var amplitude=100;
var x=transform.position[0];
var y= amplitude*math.sin(time);Christopher Rotter replied 15 years, 9 months ago 2 Members · 10 Replies -
10 Replies
-
Dan Ebberts
August 19, 2010 at 6:36 amI’m assuming it’s an expression for position. If so, it’s not complete (and “Math” needs to begin with a capital “M”). This expression works in CS3:
var amplitude=100;
var x=transform.position[0];
var y= amplitude*Math.sin(time);
[x,y]P.S. – it’s usually very helpful if you post the error message along with the expression that’s generating it.
Dan
-
Christopher Rotter
August 19, 2010 at 11:12 amI receive this error, even after fixing the expression.
After Effects Warning: Undefined value used in expression. Could be an out of range array subscript?
Expression Disabled
Error occurred at line 0.
Comp: ‘Comp 1’
Layer 2(‘Red Circle’)
Property: ‘Position’ -
Dan Ebberts
August 19, 2010 at 5:29 pmEven after adding the last line ([x,y]) ? That’s really strange. I get your error without that line, but it works fine with it.
Dan
-
Christopher Rotter
August 19, 2010 at 6:02 pmAdding [x,y] caused the expression to work. Try this expression it is not working either:
if (secondWiggleDimension > currentY)
{
var vertical = secondWiggleDimension;
}
else
{
var vertical = currentY;
}; -
Dan Ebberts
August 19, 2010 at 6:14 pmAgain, this only appears to be part of an expression. You’ve defined the variable “vertical”. Now you need to do something with it. Is this a position expression? If so you need to specify a result at the end of the expression that has values for both x and y (like your previous expression). If it’s an expression for a property with just one dimension, you could just add a reference to vertical at the end:
if (secondWiggleDimension > currentY)
{
var vertical = secondWiggleDimension;
}
else
{
var vertical = currentY;
};
verticalIf you’re just trying to test chunks of a bigger expression, then you at least always have to provide a result at the end that satisfies the dimensions of the property that has the expression.
Dan
-
Christopher Rotter
August 19, 2010 at 10:24 pmYou are right, you have to add [xPosition, yPosition] I don’t quite understand Arrays yet which is why some most of my expressions don’t work because of the Array issue. I assume only with rotation, scale you don’t need to deal with Arrays that is only a position syntax ?
-
Dan Ebberts
August 19, 2010 at 10:45 pmPosition (unless you separate the dimensions), scale, orientation, colors, point controls, stereo audio levels, (and more I’m sure) all take arrays.
Dan
-
Christopher Rotter
August 20, 2010 at 12:56 amIf you just pick whip [position] you won’t need to deal with arrays ? I hope I’m understanding.
-
Dan Ebberts
August 20, 2010 at 1:19 amIf you pickwhip to another layer’s position, you are essentially setting the position value to the position array of the other layer, and you don’t have to mess with the individual elements of the array. If you want to manipulate x,y, and z independently, you do have to deal with it as an array. You won’t get far if you don’t figure the array thing out.
Dan
-
Christopher Rotter
August 20, 2010 at 10:39 amI understand, well give me a little bit of time I hopefully should have it figured out 🙂
Reply to this Discussion! Login or Sign Up