Page 1 of 1

Changing Position of a Layer...something is weired

Posted: February 3rd, 2012, 8:48 am
by circassia
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

Re: Changing Position of a Layer...something is weired

Posted: February 4th, 2012, 12:16 pm
by Simma
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])