Page 1 of 1

Control Opacity Interactively With Slider

Posted: February 26th, 2011, 12:46 pm
by swink85
Hello,

I am designing a script with an interface that includes a slider, which should control interactively the opacity of a layer. I am able to create the slider...but I can't get it to control the opacity of my layer. Tried a bunch of different options...and looked through similar scripts' code. But I can't seem to get it to work. Any ideas?

Re: Control Opacity Interactively With Slider

Posted: March 4th, 2011, 4:10 am
by Paul Tuersley
Here's an example that will change the opacity of the first layer in the active comp:

Code: Select all

{ 	
	var pal = new Window("palette");
	pal.slider = pal.add("slider", undefined, 0, 0, 100);	
	pal.center();
	pal.show();
	pal.slider.onChanging = onSliderChange;
	
	function onSliderChange() {	
		var activeItem = app.project.activeItem;	
		if (activeItem != null && activeItem instanceof CompItem) {	
			activeItem.layer(1).property("ADBE Transform Group").property("ADBE Opacity").setValue(this.value)
		}
	}
}

Re: Control Opacity Interactively With Slider

Posted: March 16th, 2011, 11:24 am
by swink85
nice! thank you so much for your help. i hope to have my finished script soon after i get some free time.

also, wondering why you have to use "ABDE..." instead of just .opacity?

Re: Control Opacity Interactively With Slider

Posted: March 16th, 2011, 5:28 pm
by Paul Tuersley
Those are what's called matchNames, which is the universal names that don't change no matter what language you're running AE in. It ensures the script will run correctly in all languages, not just English.

Paul