If Else Conditional Expression - Adobe After Effects tutorial

Sdílet
Vložit
  • čas přidán 16. 03. 2018
  • Learn the basics of the If/Else conditional expression. It's a great way to have After Effects choose between two or even more options based on inputs. This covers the basics of the expression and some examples of how it works.
    If you have any questions just let me know in the comments.
    Download this project file:
    evanabrams.com/blog/if-else-co...
    gumroad.com/l/znHm
    Connect on the Internets
    www.EvanAbrams.com
    ecabrams
    www.Facebook.com/EvanCAbrams/
    EvanCAbrams
    Suggest a tutorial topic: docs.google.com/forms/d/13A2e...
    Google+
    plus.google.com/+EvanAbrams/
  • Jak na to + styl

Komentáře • 96

  • @MCappuc1
    @MCappuc1 Před 6 lety +4

    PLEASE make more videos explaining expressions! You have always explained concepts in AE with such clarity and I think your descriptions are more helpful for my learning process than just trying to find the info online or copy/pasting expressions from the web.

  • @luizfernandoalves857
    @luizfernandoalves857 Před 6 lety +2

    you inspire and help people more than you think, bro!
    your portifolio, your tutorials, and everything else.
    thanks for doing this

  • @ZimoNitrome
    @ZimoNitrome Před 6 lety +25

    great vid for animators/editors not familiar with programming

    • @EpicDonutDudeMemes
      @EpicDonutDudeMemes Před 6 lety +1

      Keep up your wednesday videos dude! They are amazing

    • @Evokans
      @Evokans Před 6 lety +1

      What is this? A crossover episode?

  • @Freelancer1001
    @Freelancer1001 Před 6 lety +9

    Hey Evan, really fantastic video you've made here. I love all the visual examples and how you break down each expression into parts to make it more digestible. Clearly a lot of time and thought went into this, so thank you!

    • @ECAbrams
      @ECAbrams  Před 6 lety +1

      Thank you very much. I'm glad you enjoy it :)

  • @adrianfels2985
    @adrianfels2985 Před 2 lety

    Another channel I found which is an extreme goldmine for After Effects Tutorials! I'm impressed of what you are giving us for free! Many thanks for that!

  • @UNKNOWNMAER
    @UNKNOWNMAER Před rokem

    Огромное спасибо за Ваш труд! Очень помогли в освоение темы с переменными!

  • @warlock242
    @warlock242 Před 5 lety +1

    Love your tutorials Evan, you are concise, comprehensive and amusing to boot.

  • @MudanTV
    @MudanTV Před 6 lety +2

    Dude, this is amazing, your tutorials are next level stuff. I never knew you could do conditional expressions in AE.
    Also, your last video about Essential Graphics. The box was dope, made my own version and using it quite a lot in some work related videos.
    Been following you for many years now and even though you don't post regularly, when you do, it's totally worth it!

    • @ECAbrams
      @ECAbrams  Před 6 lety

      Glad you dig it! I'm trying to get more regular. Maybe this is the year I get back to a schedule.

  • @AmitabhJangra
    @AmitabhJangra Před 6 lety

    Your speaking style is awesome.
    💙💚💛

  • @gaston.
    @gaston. Před 4 lety

    excellent explanation Evan, thank you.

  • @squeakycleanbday
    @squeakycleanbday Před 2 lety

    Thank you!

  • @ericburnett8163
    @ericburnett8163 Před 6 lety

    excellent teaching!

  • @talwag
    @talwag Před 6 lety

    amazing! thanks so much!

  • @snalvershipuchka6385
    @snalvershipuchka6385 Před rokem

    Thank you so mutch !!!You are the best ! Your video helped a lot with the project !!!

  • @ManexFX
    @ManexFX Před 6 lety

    Awesome video!

  • @pent_mo
    @pent_mo Před 2 lety

    great video!🔥

  • @bishalscreation9793
    @bishalscreation9793 Před 6 lety

    Amazing 😁 thanks a lot

  • @bluebearcreativeAU
    @bluebearcreativeAU Před 6 lety

    thank you

  • @Scott.Sandifer
    @Scott.Sandifer Před 6 lety

    Awesome!
    Thank you for this one. I think I’ll have to watch this a couple of times, since it didn’t quite stick.
    Trying to understand how the language of the expression works- and at the same time trying to take in what exactly that expression is making happen on screen got a bit fuzzy in my brain, but imma give it a few more viewings.

    • @ECAbrams
      @ECAbrams  Před 6 lety

      It can be a hard one to crack. It took a while for me to grok expressions when I started getting into it and I'm still getting those ah-ha moments.

  • @DamonBowe
    @DamonBowe Před 6 lety

    awesome tutorial, eca!

  • @lenisiojardim
    @lenisiojardim Před 6 lety

    Thanks!

  • @LongerTomTV
    @LongerTomTV Před 6 lety +2

    Awesome! Expressions in AE were always a thing I would like to use more often but I didn't have enough knowledge about. Pls Evan, do more of those :D

    • @ECAbrams
      @ECAbrams  Před 6 lety +2

      I think that can be arranged :)

  • @abacadusale
    @abacadusale Před 6 lety

    Very, very interesting topic to tackle, Evan :D

  • @bush9686
    @bush9686 Před 6 lety

    Thank you mister)

  • @SlimeyNoCommentary
    @SlimeyNoCommentary Před 6 lety

    Thankk you

  • @NerdGeekFutureSpeak
    @NerdGeekFutureSpeak Před 6 lety

    Woo! So expressive 🙂

    • @ECAbrams
      @ECAbrams  Před 6 lety +2

      Just like Dr. Dre says, "There's no fessing or guessing while I'm expressing myself" ;)

  • @thiroux
    @thiroux Před 6 lety

    Great!!

  • @SlimeyNoCommentary
    @SlimeyNoCommentary Před 6 lety

    Thann you

  • @Videos-gk6yt
    @Videos-gk6yt Před 4 lety

    Hi, thanks for the video, it's really interesting.
    This is completely new for me, so I would like to know more fundamentals, where could I learn it from the beginning?

  • @goodgamist5113
    @goodgamist5113 Před 4 lety +1

    I like how he used if/else for the intro

  • @JoeSparks
    @JoeSparks Před 6 lety

    I've learned so much from you over the past year. I hope it shows in my latest music video: "After Effects, I Love You"

  • @LeonVeryNeijs
    @LeonVeryNeijs Před 6 lety

    Awesome tutorial, as always!

  • @SaeedDesigner7
    @SaeedDesigner7 Před 3 lety

    thank yyyyyyyyyyyyyooooooooooooooooooooooouuuuuuuuuuuuuu

  • @nseriously2704
    @nseriously2704 Před 5 lety

    I didnt understand! but thx! hope I can get it soon!

  • @luizfernandoalves857
    @luizfernandoalves857 Před 6 lety

    Just on my studying time! Brazil likes, you, bro! lol

    • @ECAbrams
      @ECAbrams  Před 6 lety

      Obrigado! Gostaria de aproveitar.

  • @KhalidObi
    @KhalidObi Před 6 lety

    Thank you for sharing this. I fell in love with expressions after your video on sourceRectAtTime. It's very fun and time-saving to play around with and use expressions.

  • @phendan
    @phendan Před 6 lety

    Really well-done video. Only thing that could make it better is if you also made the intro bit available for download/purchase :P

  • @keifferbuckles8976
    @keifferbuckles8976 Před 6 lety

    more expressions videos!

  • @GammelSami
    @GammelSami Před 4 lety

    haha, i looked this up, because i'm working on a dial display like composition. and you have one in the video too...

  • @-________9732
    @-________9732 Před 2 lety

    Cool. +++

  • @Feisproductions
    @Feisproductions Před 6 lety

    I did not know you could skip the " { } " symbols in the statement. That's kind of convenient! although it might get a bit confusing for me without the full syntax because now its just a bunch of numbers together.

    • @ECAbrams
      @ECAbrams  Před 6 lety

      Absolutely. It's a good habit to have for formatting. There is also a plugin people use for expressions that reformats the expression window to be more like a proper code editor that can really help with organization.

  • @TheFiXNormal
    @TheFiXNormal Před 6 lety

    Great vid, Evan. As someone who literally never used any kind of programming in AE (or in fact anywhere else), could you, please, recommend me some material to study while I'm not on PC? :) Cheers and keep it up!

    • @ECAbrams
      @ECAbrams  Před 6 lety +1

      Well, since expression language is based on JavaScript, some light reading on the basics of JS would be a good move. Something like "JavaScript: The Good Parts" by Douglas Crockford might be a nice read. I've heard good things but never read After Effects Expressions by Marcus Geduld as well.

    • @TheFiXNormal
      @TheFiXNormal Před 6 lety

      Thank you for the reply. I will look into both. Cheers!

  • @TheSoul1988
    @TheSoul1988 Před 5 lety

    Can you do something similar but with position. Like if NULL is in position (X,Y) then something

    • @ECAbrams
      @ECAbrams  Před 5 lety +1

      Absolutely. You can do any inputs and outputs that you like so long as you phrase them correctly. So it might be something like if (transform.position==[10,50]) {something} else {something else}

  • @andriyprvdn1777
    @andriyprvdn1777 Před 4 lety

    Hi! Thanks.
    But how do I make the value change gradually? Does anybody know?
    For instance if scale is more than 50, then I want opacity grow from 50 to 70 within 2 seconds. Is that possible?

    • @ECAbrams
      @ECAbrams  Před 4 lety

      Hi. As we say about expressions "anything is possible". Are you looking to use the scale as a trigger in this example?

    • @andriyprvdn1777
      @andriyprvdn1777 Před 4 lety

      @@ECAbrams Thanks for the reply!
      I have a null with keyframed rotation. The rotation varies, it goes from 0 to -184, then from -184 to -94, etc. It is, basically, a steering wheel.
      Whenever my steering wheel starts to rotate counter-clockwise I want to have this effect: scale gradually (within 1 second) goes from 100 to 90. When the wheel starts to rotate clockwise I want scale to go from 90 to 100.
      It's like when you have two buttons which rotate the wheel; when press left - it rotates counter-clockwise, right - clockwise. Except, it is the opposite - it's the wheel that pushes buttons. (Wow I hope it is understandable).

  • @anikaschulz6433
    @anikaschulz6433 Před 4 lety +1

    If you get an expression error in Adobe 2019:
    File > Project Setting > Expressions > change Java Script to Legacy ExpandScript

  • @rodgerhunter41
    @rodgerhunter41 Před 5 lety

    Great tutorial, how do I use multiple if statements. I’m trying to change the display text based on the output of a slider control A
    eg......
    if (A=-180){“white”}
    if(A=-108){“blue”}
    If(A=-32){“green”}
    A
    Thanks to anyone who may be able to help

    • @ECAbrams
      @ECAbrams  Před 5 lety

      Hey Roger, you're actually very close already. You just need more "elses" in there. so it would be
      if (this) {that} else
      if (this) {that} else
      if (this) {that} else
      {that}
      Let me know if that gets you the results you're after.

  • @alexaraya2018
    @alexaraya2018 Před 2 lety

    what was the command to output a value to a .....window in after effects to monitor variables and other changing values.....was it put?

    • @ECAbrams
      @ECAbrams  Před 2 lety

      Sorry, you would like to send the value of a property out of after effects? Is that the idea?

    • @alexaraya2018
      @alexaraya2018 Před 2 lety

      @@ECAbrams Sorry I got confused with old flash or director...they used to have a window for monitoring values for debugging, you would ad a line of code "put [variable]" and the value would come up in that window...I think that in aftereffects you have to pickwhip a text layer value to that other layer's variable.. :Can you do that?

  • @HexenHex-jt6ot
    @HexenHex-jt6ot Před 2 měsíci

    simple question, let's take the first expression as an example:
    If (x>45) {100}
    else {0}
    it works, but it's too sudden, from 0 to 100 and 100 to 0, would it be possible to smooth the process? like, once the x hits 45 the value goes from 0 to 100 but not instantly?

    • @ECAbrams
      @ECAbrams  Před 2 měsíci +1

      I suppose the solution will depend on what you expect to see happen. If you mean that once a number crosses 45 it sould trigger an animation, that's a little complex. I would recommend looking at the work of Dan Ebberts at motionscript.com to get into triggering animations using values or markers.
      But, you might find what you want in the interpolation functions like linear(). For example you could do linear(x,45,100,0,100). That would give you an output that got from zero to 100 as x goes from 45 to 100. So from 0 till 45 the output is zero, then it has a linear change from 45 up to 100. You might also use the ease() functions for a more gradual roll on and off.
      Does that make sense?

  • @dmellis
    @dmellis Před 3 lety

    At 6:18 that statement if (R>0 && R

    • @ECAbrams
      @ECAbrams  Před 3 lety

      It looks like you've made an error in there. the structure should be
      if (condition in parentheses) {then what happens in curly braces} else {then what happens if else again in curly braces}
      if the expression is exactly as you've got it in this comment, using a [ in place of a { that would be my suggestion for where to start trouble shooting. But let me know what error you're getting and I'll try to help if I can.

  • @paulscholesisgod
    @paulscholesisgod Před 6 lety

    Evan, I know this is completely unrelated to expressions, but can you tell me how you got that infinity symbol looking so god damn perfect? Did you pull that from Illustrator or did you make it in AE? If you did make it in AE.... blink twice.

    • @ECAbrams
      @ECAbrams  Před 6 lety

      I think I drew it in Ae. I just used the grid.

    • @paulscholesisgod
      @paulscholesisgod Před 6 lety

      Thanks, Evan. Really appreciate you taking the time out making these tutorials.

  • @karlamata7421
    @karlamata7421 Před 5 lety

    i tried to put an expression in scale property but i keep getting error that needs 2 dimensions not 1?looks something like this
    this is in the scale property i also added a checkbox control ,basicly i want scale to change when checkbox is on ?can u help
    var checkbox=effect("Checkbox Control")("Checkbox")
    if(checkbox==0);
    100;
    }else{
    0;
    };

    • @ECAbrams
      @ECAbrams  Před 5 lety +1

      Absolutely. When you get an error like that, it's because you're not formatting the output in a way the property needs. Scale for example is of dimension 2. We always see it displayed as [x,y]. It has two dimensions, a horizontal and vertical. So you would need your outputs to be something like [100,100] and [0,0]. Right now your outputs are of dinemsion 1, would would be fine for opacity or rotation, properties of dimension 1 that only need a single number. If you format your outputs as an array [this,that] you'll be fine.

    • @karlamata7421
      @karlamata7421 Před 5 lety

      ECAbrams thanks for the reply I understand but seems something is still wrong
      var checkbox=effect("Checkbox Control")("Checkbox")
      if(checkbox==0);
      [100,100];
      }else{
      [0,0];
      };
      Or am i still doing it wrong how would you right the code?

    • @ECAbrams
      @ECAbrams  Před 5 lety +1

      @@karlamata7421 well, there is a lot off about what you've got. You have a lot of ";" and not in the right places. Some { } that don't open. Let's simplify to:
      checkbox=effect("Checkbox Control")("Checkbox");
      if(checkbox==0) {
      [100,100]
      }
      else
      {[0,0]
      }

    • @karlamata7421
      @karlamata7421 Před 5 lety

      @@ECAbrams thanks i saw the problem now and its working!thank you!

  • @khanlakhno2757
    @khanlakhno2757 Před 6 lety +1

    Hello! Wchich language these scripts work on? I began to study php and JS and for me these expressions look like they've been written in JS. Am I wrong?

    • @khanlakhno2757
      @khanlakhno2757 Před 6 lety

      btw, thank you for your tutorials) Greetings from Russia :D

    • @ECAbrams
      @ECAbrams  Před 6 lety +2

      Not wrong at all, actually very right. I believe that the Ae Expression Language is based on, and incredibly similar to, JavaScript.

  • @hqproductionpotfolio2067

    You forgot to nitce that ar AE 2018 toy fhould put == (or >= or

    • @ECAbrams
      @ECAbrams  Před 4 lety

      We use many logical operators in the video, and there are more besides, it's true.

  • @AaliDGr8
    @AaliDGr8 Před měsícem

    help mere

  • @mediocreape
    @mediocreape Před rokem

    haha did you say "aboot" instead of about. you candians are funny.

    • @ECAbrams
      @ECAbrams  Před rokem +1

      Oh no! You caught me being a Canadian on the internet. You win 3 wishes I guess?

  • @joshbradyvideo1713
    @joshbradyvideo1713 Před 4 lety

    "go outside"
    thanks

  • @floppydisk9541
    @floppydisk9541 Před 5 lety

    After effects is basically adobe flash + Photoshop..

    • @ECAbrams
      @ECAbrams  Před 5 lety +1

      + illustrator + premiere ;)

  • @Berserker_BG
    @Berserker_BG Před 6 lety

    expressions..... ugh

    • @Berserker_BG
      @Berserker_BG Před 6 lety

      Oh wow, i just watched the actual tutorial and I have to say this guy presented boring expressions in a very entertaining way. It wasn't even boring as I expected, in fact, it was pleasing. Great job mister, you are my new hero.

  • @brunopoplocker
    @brunopoplocker Před 5 měsíci

    MAN, just a tip: most of the times when we are looking for a tutorial we are in a hurry, so, the longer it takes you to say what matters, the more it bothers you. Try to leave the presentations until the end, when we have already seen the tutorial and solved our problem. then we will be happier and more willing to listen to what else you have to say.

  • @aagfx2958
    @aagfx2958 Před 4 lety

    SHOW ME how can i to give you 1000 like?

  • @MiasSteenberg
    @MiasSteenberg Před rokem

    Hey, so I'm trying to count from one date to next and set the date via slider, but just not winning with expression. Would also like to be able to only count from "mmm-yyyy" to "dd-mmm-yyyy" this is what I have:
    monthnames=["JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"];
    Speed=effect("Time")("Slider");
    date_1=new Date(2020,0,12); // watchout month 0= january, 11=:december !
    milli_1=date_1.getTime();
    date_2=new Date(2023,3,20);
    milli_2=date_2.getTime();
    t=linear(time,0,Speed,milli_1,milli_2);
    date_3=new Date(t);
    date_3.getDate() + " " + monthnames[date_3.getMonth()] + " " + date_3.getFullYear() ;

    • @ECAbrams
      @ECAbrams  Před rokem

      Maybe this article on the date function will help: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
      As I understand it we need to count or convert into milliseconds when adjusting dates. Maybe I'm wrong on that, though. I don't do much formatting of values into dates. BUT what I gather is that to count from one date to another we want to be adding to the milliseconds that the date constructor is referencing which might require something as simple as multiplying that linear result by a very large number and then converting that number (milliseconds) back into a date?
      Does that help at all?