ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Add values to an empty array

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Padraic Rapp
Add values to an empty array
on Nov 25, 2019 at 3:16:49 pm
Last Edited By Padraic Rapp on Nov 25, 2019 at 3:17:36 pm

Hey ya'll !
I am trying to create a shape layer path based on a target layer's position.
this expression:
createPath(points = myPoints, inTangents = [], outTangents = [], isClosed = false);
lets me create a path based on an input array ("myPoints").

I want this array to be dynamic for a lack of a better term ( I am no programmer), i.e. I want to add values to this array and I thought I could use something like this:

tCount = 0; // time counter
tInter = 0.5; // time interval (samples)
myPoints = []; //an empty array to store the path points

myPoints += thisComp.layer("target").transform.position.valueAtTime(tCount);
tCount += tInt;

The first line in the while loop returns an error ("Undefined value used in expression"). I thought I could add values to an empty array but I guess I'm doing something wrong. Can somebody help me out with this? How DO you add values to an array? Or should I be generating a string inside the "myPoints" array that contains all the points based on a similar while loop?

Any help is greatly appreciated!

Return to posts index

Dan Ebberts
Re: Add values to an empty array
on Nov 25, 2019 at 5:00:34 pm

The easiest way would be to use push(), like this:



Return to posts index

Padraic Rapp
Re: Add values to an empty array
on Nov 26, 2019 at 7:41:59 am

YES! works perfectly. Thank you so much Dan!

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 All Rights Reserved