Control Opacity Interactively With Slider

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
swink85
Posts: 13
Joined: January 5th, 2010, 1:37 am

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?
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

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)
		}
	}
}
swink85
Posts: 13
Joined: January 5th, 2010, 1:37 am

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?
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

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
Post Reply