Changing Position of a Layer...something is weired

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
circassia
Posts: 4
Joined: March 9th, 2011, 6:25 am

Hi Guys,

messing around with someone elses working script
"randomShifterScript" i tried to change some parameters, as i would like to set randomly the position of layers.

Code: Select all


.
..
...
var selectedLayers = myComp.selectedLayers;
				if (selectedLayers.length != 0) {
				
				
				for (i = 0; i < selectedLayers.length; ++i) {
						
					var dotsMin = 0;
					var dotsMax = 1024;
					var myRandomDots = min + ((dotsMin-dotsMax)*Math.random());
					var currentLayer = selectedLayers[i];
					currentLayer.startTime += myRandom;
					currentLayer.transform.position[0] = 200;
					...
					..
					.
currentLayer.transform.position[0] = 200;

this code seems to be wrong, but i tried different things...and found also a lot of old code, but maybe one of you could tel what the right syntax is.

What it does: Select all layers, than randomly set the new positin.

thank you very much
Simma
Posts: 98
Joined: June 8th, 2010, 2:57 pm

You must use "setValue()" to set a new value. Also remember that position values are stored in an array [x,y] (and z if it's a 3d layer).

Try:
currentLayer.position.setValue([200,200])
Post Reply