Click here to Skip to main content
15,562,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I'm using extendscript(a form of javascript) that works with adobe after effects scripts. I want the function SLIDERCHECKER() to run every frame while the video is playing/rendering in after effects.I am trying to make the script play when I click the play button in after effects. The script is suppose to constantly turn on and off layers by sliderValue(of another layer) while playing.

Here's the after effects reference: After Script Reference Guide[^]


var firstLayer = app.project.item(1).layer(1);
var secondLayer = app.project.item(1).layer(2);
var thirdLayer = app.project.item(1).layer(3);
var fourLayer = app.project.item(1).layer(4);


var sliderValue1 = secondLayer.effect(1).property(1).value;
var sliderValue2 = fourLayer.effect(1).property(1).value;


SLIDERCHECKER();
    
    
function SLIDERCHECKER(){
  
  app.beginUndoGroup("My script action");
  
  if (sliderValue1 > .7  && sliderValue2 < .7)
  {
  
     firstLayer.opacity.setValue(100);
     thirdLayer.transform.opacity.setValue(0);
    // alert("sliderValue1 is higher");
  }
  else if (sliderValue2 > .7 && sliderValue1 < .7)
  {

    thirdLayer.opacity.setValue(100);
    firstLayer.opacity.setValue(0);
    //alert("sliderValue2 is higher");
  }
  else if (sliderValue1 > .7 && sliderValue2 > .7) 
  {
    
   firstLayer.transform.opacity.setValue(100);
   thirdLayer.transform.opacity.setValue(0);
   //alert("both are equal");
  }

  app.endUndoGroup();
  
}


What I have tried:

I tried a while loop but when i go to test it, it freezes and i have to go to code editor and stop it.

var x = 4;
while (x < 5){
    
SLIDERCHECKER();

    }


Also, I tried using a button that toggles on and off, the goal behind was to make it run over and over while on but its only checks it once.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900