Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Multiple checkbox related to each other with expressions

  • Multiple checkbox related to each other with expressions

    Posted by Daniel Futerman on January 8, 2014 at 5:29 pm

    Hi guys,

    I’ve been trying quite hard to get this to work but I can’t seem to figure it out alone.
    I have 3 checkbox controls, each one a different layer (A, B, C).

    The idea is a three way checkbox selection which coordinates with each other in the following way:

    1. If A Checkbox is Enabled, then B Checkbox is Disabled.

    2. If B Checkbox is Enabled, then A Checkbox is Disabled.

    3. If C Checkbox is Enabled, then A Checkbox & Checkbox B are Enabled.

    So I created an expression (attached below) and pasted it in layers A & B (switched around the X/Y in layer B). Layer C has no expressions, only the checkbox control.

    Up to here, everything works fine..

    The problem is that I’m getting all kinds of strange behaviours from different layers doing things they’re not meant to do..

    Many different layer properties around the project are connected to the these checkboxes. For example – if Checkbox A is Enabled – Layer White opacity is 100% – Which means – Layer Black opacity is 0%. This happens because layer Black is connected to Checkbox B which is now disabled because A is Enabled. (When Checkbox B is disabled, Layer black opacity goes to 0%).

    Wow I hope I’m describing this well enough..

    Until now it’s was all working great. But then.. I have another layer. This layer is has a ‘fast blur’ effect, and the fast blur properties are connected to layer D’s Slider control. Layer D has no relationship whatsoever to Layers A, B or C.

    But – when I slide layer D slider, suddenly layers a & b switch their opacity values. A goes to 0% opacity and layer B goes to %100. i.e. Layer A’s checkbox ticks off and B’s ticks on.

    I’ve double and triple checked everything and I really can’t find any relationship between the two things. I assume there is something I am not familiar with about expressions.

    If you managed to understand what I’m trying to do, I’d love to hear your thoughts about this and what I am doing wrong.
    Many thanks,
    Daniel

    x = thisComp.layer("a").effect("Use This")("Checkbox");
    y = thisComp.layer("b").effect("Use This")("Checkbox");
    z = thisComp.layer("c").effect("Use This")("Checkbox")

    if ( x == 1) {
    y = 0;
    }

    if ( x == 0) {
    y = 1;
    }

    if ( z == 1) {
    y = 1;
    }

    After Effects Template & Photoshop Tutorials:
    https://www.amigo-productions.com

    Panagiotis Mouzakis replied 11 years, 8 months ago 5 Members · 11 Replies
  • 11 Replies
  • Dan Ebberts

    January 8, 2014 at 6:19 pm

    I don’t think you’re going to be able to get predictable results. The expression for A depends on B, but the expression for B depends on A. I don’t think there’s any way that can work.

    Dan

  • Daniel Futerman

    January 8, 2014 at 6:31 pm

    Thanks for your quick reply Dave!

    That’s exactly the thing though, I don’t understand why a completely random layer with a ‘fast blur’ effect connected to a slider controller (on another different layer) – would affect the checkboxes which work perfectly otherwise.. Hmm..

    Do expressions throughout the comp execute randomly or something like that? Is that why you said I wont be able to predict the results?

    If I’m getting it all wrong here, do you possibly have a suggestion for how to make this work? It’s basically for a control panel for a template I’m working on and I want to make it super simple for the user to edit..

    Thanks again! 🙂

    After Effects Template & Photoshop Tutorials:
    https://www.amigo-productions.com

  • Kevin Camp

    January 8, 2014 at 7:55 pm

    it’s hard to tell why the blur is effected, but the issue is probably with the ‘c’ control…

    if c is true, then both a and b are true… but a must be false if b is true, or b must be false if a is true. so it’s a logic issue.

    you might be able to try something like this with an ‘or’ opperator (‘||’):

    x = thisComp.layer("a").effect("Use This")("Checkbox");
    y = thisComp.layer("b").effect("Use This")("Checkbox");
    z = thisComp.layer("c").effect("Use This")("Checkbox");

    if (x == true) false;
    if (x == false || z == true) true;

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Daniel Futerman

    January 9, 2014 at 6:54 am

    Hey Kevin,
    Thanks for your help.

    I played around with the expressions and also implemented the one you suggested with and addition of else = false code, and for the most part it’s done the job. It still seems like at random times the layers flip around and I really don’t get why this is, but 95% of the time it’s working as expected.

    It’s actually turning out to be quite a complex and cool project, I’ll give you the heads up when it’s out there so you can see what you’ve been helping me with 😉

    OK.. Going to concentrate hard on solving those last 5% now!
    Thanks again guys!

    After Effects Template & Photoshop Tutorials:
    https://www.amigo-productions.com

  • Kevin Camp

    January 9, 2014 at 9:30 pm

    this might be slightly better:

    x = thisComp.layer(“a”).effect(“Use This”)(“Checkbox”);
    y = thisComp.layer(“b”).effect(“Use This”)(“Checkbox”);
    z = thisComp.layer(“c”).effect(“Use This”)(“Checkbox”);

    if (z == true) true;
    else if (y == false) true;
    else false;

    but there will always be an inconsistency when toggling the ‘c’ control. if you select ‘b’ to be true, ‘a’ becomes false. if you then select ‘c’ to be true, both ‘a’ & ‘b’ become true. if you toggle ‘c’ back to false, ‘a’ will be true and ‘b’ will be false.

    i assume this happens due to order of evaluation of each expression, which is probably the layer order (top most being evaluated first).

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Daniel Futerman

    January 13, 2014 at 11:21 am

    Hey Kevin, thanks for your idea – I think it does work better but now I’m getting some other weird behaviors.
    Perhaps what I’m trying to accomplish isn’t possible with AE but I really want to believe it is..

    The project is really quite complicate and has tons of different layers and effects being controlled by all these checkboxes, so it’s actually very difficult to ask for help considering you’re not familiar with the project. But I’ll do my best to try explain and ask the right questions which lead to my understanding of the problem.

    So this is where I’m at – the 3 way checkbox controls (from the first post) and all the connected layers are working great.

    What I’m trying to do now, is a 4 or actually a 5 way checkbox, with a slightly different format. If Z is True + One of the other checkboxes (A,B,C or D) is true, then only that specific checkbox (A,B,C or D)is True. And I got it working with the expression below.

    There are several other layers in the project which are connected to these checkboxes, for example if B checkbox is True, then Comp “Circle” opacity is 100% otherwise 0% opacity. Up to here it’s all working great.

    This is where it get’s strange.

    There seems to be a different between the checkbox “On/Off” property when controlled manually, or controlled with the expression. This is what happens (I’ll use only A & B to explain):

    A = On (Via Expression)
    B = Off (Via Expression)

    Result:
    Specific comps in the project do not work properly, mainly issues to do with alpha channels.

    A = On (Manually)
    B = Off (Via Expression)

    Result:
    Everything works perfectly.

    Conclusion:
    When A is On using Expression, things don’t work
    When A is On Manually, things Do work.

    I wouldn’t have thought there should be a difference between the two scenarios.. but there is, and I have no idea why. And this is true also for all the other checkboxes. If they are on/off Manually everything works great, but if via expressions things go wrong.

    Thanks for taking the time to read all of this and try to understand it, I really do appreciate your help.
    Daniel

    z=thisComp.layer("Shape on / off").effect("Turn Shape On or Off")("Checkbox")
    a=effect("Checkbox Control")("Checkbox")

    b=thisComp.layer("Circle").effect("Checkbox Control")("Checkbox")
    c=thisComp.layer("Hexagon").effect("Checkbox Control")("Checkbox")
    d=thisComp.layer("Box Rounded").effect("Checkbox Control")("Checkbox")

    if ((z==true)&&(a==true)&&(b==false)&&(c==false)&&(d==false)) true;
    else false;

    After Effects Template & Photoshop Tutorials:
    https://www.amigo-productions.com

  • Kevin Camp

    January 13, 2014 at 9:42 pm

    it may be due to the order of the expressions… assuming that ae processes the expressions in order of layer order (which is what it seems to do), your would need your check box expression to be the topmost layers.

    however, to make things easier, i think i’d try putting all the check boxes on a single null (name it ‘controls’ or something), and name each check box for what it does. it can make updating easier if there is only one place to look, and a little more intuitive to see all the options in one place. you can even add a layer marker and comment telling the user to use controls on that layer before rendering.

    then i’d remove the expressions from the check boxes and just train the user on which check boxes do what, and any rules, like at least on check box must be selected, but never more than two, or whatever…

    you could then create a text layer at the top of the comp, make it a guide layer so it won’t render, and then have you check boxes change the text to help them out… like if no check boxes are checked it says ‘please select one check box’ or if 2 ‘non-compatible’ check boxes are checked, it would alert them to uncheck one of the check boxes.

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Daniel Futerman

    January 15, 2014 at 8:47 am

    Thanks Kevin that’s not a bad idea at all, but I really want to try and nail this one with the current layout 🙂 But if it continues to be so difficult I might have to try the 1 null method.

    This project is really helping me explore the boundaries of AE and it’s crazy how many new things I’ve learned during the whole process! Anyways I’ll keep you posted once I have any further insights.

    Thanks again, appreciate it.

    After Effects Template & Photoshop Tutorials:
    https://www.amigo-productions.com

  • Daniel Futerman

    February 2, 2014 at 6:19 am

    Hey Kevin & Dan,
    As promised I’m back to share the final result of the project 🙂

    After all the experiments I’ve done with expressions and key-frames, I’ve decided to go ahead with your suggestion Kevin and have multiple check-boxes on each null.

    Here is an image of the interface:

    So for example, if the null of the Logo’s Left Shadow is ON, the null of the Right Shadow should turn Off.
    And actually, the shadow controllers where behaving quite well, but I had issues when trying to adjust the Length or Softness (blur) of the shadows when for some reason the shadow would also flip..

    But the main issue happened with the shape controls. If for example you selected the circle shape and then ram previewed the animation, at certain seconds the shape would change back to a different shape. This was happening because something was affecting the check boxes and causing them to switch on/off with out the user interference. But every check I did suggested there was no consistency in the reason this happened and it seemed to happen randomly.

    Obliviously for a template I couldn’t allow this to happen because I needed the user to have full control.

    The original idea was to have each controller on a separate null and then create an automatic interface where if you click on one check box it deactivates the others – like in the image bellow, where the Logo shadows have 3 nulls attached to each shadow option. But I ended up having one null with 3 check boxes on each setting, like on the Shape shadow settings:

    (In the shape control there are 4 check boxes..)

    So any ways, I just wanted to say thank you again for your help in trying to solve this. In the end I think the idea Nick suggested was the best solution and I ended up doing it. If you’d like to see the final result and some more information about this project you can head over here, and if you want to have an inside look of the project you can have a look at the video tutorial 🙂

    Thanks a lot for you help guys, I really do appreciate it!
    Daniel

    After Effects Template & Photoshop Tutorials:
    https://www.amigo-productions.com

  • Dane Blacic

    August 4, 2014 at 4:57 am

    Hey guys,
    I have found a solution for this…
    The problem is that First Checkbox always gets reactivated if I try to change the color or even if I uncheck the effect visibility…
    I have 4 checkboxes on a single null…

    Any suggestions?
    Thx

    // this is for the first one
    var a = effect("Color Scheme 01")("Checkbox").value ;
    var a1 = effect("Color Scheme 02")("Checkbox").value ;
    var a2 = effect("Color Scheme 03")("Checkbox").value ;
    var a3 = effect("Custom Color Scheme")("Checkbox").value ;

    if ( a1 == 1 || a2 == 1 || a3 == 1 ){
    a = 0 ;
    }else
    {
    a = 1 ;
    }

Page 1 of 2

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