Scripting an everyday task
Hello folks, I'm trying to replicate, in a script I can just run, what I do to video layers at the end of a project for Video Walls we produce at a local TV station.
Basically, I enable Time Remapping and then extend out the layer (just the layer box/container, not the time keyframes) to the end of the remainder of the current comp. Our vWalls generally only contain movement for the first 8 to 10 seconds and then there's 30 second tail, so we extend out the layer (not the keyframes) in order to keep the last frame on screen until the presentation has finished. Problem is we sometime forget to extend that final layer out (and when it's as busy as it was last night, this can go unoticed until it's too late), but if we got used to using a specific script/clicking a button for this, there'd probably be more chance that we'd remember to do it, purely from the novelty of performing a unique action to do so, if that makes any sense!...
So, I've written this in ExtendScript (cobbled together from snatches of script I've seen online) but of course, I can't figure out why it won't work - being an absolute beginner with scripting in AfterEffects:
var window = new Window("palette","Flood Layer",undefined); var StartButton = window.add("button",undefined,"Run!"); window.show(); StartButton.onClick = function(){ var comp = app.project.activeItem; var layer = comp.selectedLayers; for(var i = 0; i < layer.length; i++){ layer.TimeRemapEnabled = true; layer.duration = comp;} }
I imagine this is a simple script to fix/write properly and I do intend to continue my journey in Scripting AE but any help at this stage would be greatly appreciated.
Thanks for your time.
