Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Change checkbox True/False with a button (if/else?)

  • Change checkbox True/False with a button (if/else?)

    Posted by Vincenzo Imbimbo on September 7, 2022 at 4:03 pm

    Hi guys, i’m trying to create a button that when you click it a checkbox would change it’s state, if its “false” then it will change to “true”, and if it’s “true” then it will change to “false”. I got it working but the problem is that only works once, then no longer changes, i want it to change everytime i press the button, what am i doing wrong?

    This is the code:

    myButton.onClick = function(){

    app.beginUndoGroup("myScript");

    var myLayers = comp.selectedLayers;

    for (var i = 0; i < myLayers.length; i++){

    myLayers[i].effect("APC Colorama").property(12).setValue(false)

    ? myLayers[i].effect("APC Colorama").property(12).setValue(false)

    : myLayers[i].effect("APC Colorama").property(12).setValue(true);

    }

    app.endUndoGroup();

    }

    Vincenzo Imbimbo replied 3 years, 11 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    September 7, 2022 at 4:35 pm

    I haven’t tested this, but it seems like you’d want to do it this way:

    myLayers[i].effect("APC Colorama").property(12).value
    ? myLayers[i].effect("APC Colorama").property(12).setValue(false)
    : myLayers[i].effect("APC Colorama").property(12).setValue(true);
  • Vincenzo Imbimbo

    September 7, 2022 at 4:48 pm

    MY GOD, you are a life saver Dan! Thank you so much.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy