set a layers opacity?

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
farsighted
Posts: 2
Joined: November 4th, 2008, 4:01 am

Hey,

I'm very new to scripting (i first tried it today) and I have a couple of questions.
Firstly, where can I find a reference of all the functions etc? I'm all googled out...

Then, I have this script I wrote and it's working fine, but I need to set a layers opacity, but I'm getting nowhere.

The script just adds adjustment layers with presets set on them. Here's the code for adding one of the layers:

Code: Select all

var adjLayer2 = mainComp.layers.addSolid([1,1,1],"desaturate", mainComp.width,mainComp.height,mainComp.pixelAspect,mainComp.duration);
adjLayer2.adjustmentLayer = true;
adjLayer2.applyPreset(highPass);
adjLayer2.blendingMode = BlendingMode.COLOR;
adjLayer2.opacity = LayerOpacity(50); //This is where I'm stuck - I've tried countless options here to no avail
I tried searching for examples and references, but I didn't find much. Any help would be awesome.

Thanks
User avatar
Atomic
Posts: 157
Joined: April 30th, 2007, 5:55 am
Location: United States, Ohio

Here is some example code that might get you going.

It fades a layer over time.

Code: Select all

	//Auto animate the fade in and out for this layer. 
	myOpacity= curLayer.property("opacity"); 
	myOpacity.setValueAtTime(curIn,0); 
	myOpacity.setValueAtTime(curIn + 0.25,100); 
	myOpacity.setValueAtTime(curOut - 0.25,100);		//Effectively creates a hold frame, can cause problems on interlace footage. 
	myOpacity.setValueAtTime(curOut,0); 
"Up And Atom

No...No

Up And At Them!"
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

If you don't need keyframes, you can just do this:

adjLayer2.property("opacity").setValue(50);


The Scripting Guide is your friend:

http://www.adobe.com/products/aftereffe ... _guide.pdf

Dan
farsighted
Posts: 2
Joined: November 4th, 2008, 4:01 am

Thanks Dan,

I don't need to animate the property so that will be perfect!

Thanks so much!

I downloaded the guide... :)

Shane
Post Reply