If Else Conditional Expression - Adobe After Effects tutorial

Поділитися
Вставка
  • Опубліковано 16 бер 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/
  • Навчання та стиль

КОМЕНТАРІ • 96

  • @MCappuc1
    @MCappuc1 6 років тому +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 6 років тому +2

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

  • @adrianfels2985
    @adrianfels2985 2 роки тому

    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!

  • @Freelancer1001
    @Freelancer1001 6 років тому +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  6 років тому +1

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

  • @gaston.
    @gaston. 4 роки тому

    excellent explanation Evan, thank you.

  • @warlock242
    @warlock242 5 років тому +1

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

  • @UNKNOWNMAER
    @UNKNOWNMAER Рік тому

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

  • @MudanTV
    @MudanTV 6 років тому +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  6 років тому

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

  • @snalvershipuchka6385
    @snalvershipuchka6385 Рік тому

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

  • @ZimoNitrome
    @ZimoNitrome 6 років тому +25

    great vid for animators/editors not familiar with programming

    • @EpicDonutDudeMemes
      @EpicDonutDudeMemes 6 років тому +1

      Keep up your wednesday videos dude! They are amazing

    • @Evokans
      @Evokans 6 років тому +1

      What is this? A crossover episode?

  • @pent_mo
    @pent_mo 2 роки тому

    great video!🔥

  • @AmitabhJangra
    @AmitabhJangra 6 років тому

    Your speaking style is awesome.
    💙💚💛

  • @ericburnett8163
    @ericburnett8163 6 років тому

    excellent teaching!

  • @squeakycleanbday
    @squeakycleanbday 2 роки тому

    Thank you!

  • @ManexFX
    @ManexFX 6 років тому

    Awesome video!

  • @talwag
    @talwag 6 років тому

    amazing! thanks so much!

  • @abacadusale
    @abacadusale 6 років тому

    Very, very interesting topic to tackle, Evan :D

  • @bishalscreation9793
    @bishalscreation9793 6 років тому

    Amazing 😁 thanks a lot

  • @LongerTomTV
    @LongerTomTV 6 років тому +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  6 років тому +2

      I think that can be arranged :)

  • @DamonBowe
    @DamonBowe 6 років тому

    awesome tutorial, eca!

    • @ECAbrams
      @ECAbrams  6 років тому

      Thanks! Glad you dig it.

  • @bush9686
    @bush9686 6 років тому

    Thank you mister)

  • @lenisiojardim
    @lenisiojardim 6 років тому

    Thanks!

  • @bluebearcreativeAU
    @bluebearcreativeAU 6 років тому

    thank you

  • @thiroux
    @thiroux 6 років тому

    Great!!

  • @SlimeyNoCommentary
    @SlimeyNoCommentary 6 років тому

    Thankk you

  • @Scott.Sandifer
    @Scott.Sandifer 6 років тому

    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  6 років тому

      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.

  • @NerdGeekFutureSpeak
    @NerdGeekFutureSpeak 6 років тому

    Woo! So expressive 🙂

    • @ECAbrams
      @ECAbrams  6 років тому +2

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

  • @SlimeyNoCommentary
    @SlimeyNoCommentary 6 років тому

    Thann you

  • @Videos-gk6yt
    @Videos-gk6yt 4 роки тому

    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?

  • @LeonVeryNeijs
    @LeonVeryNeijs 6 років тому

    Awesome tutorial, as always!

  • @nseriously2704
    @nseriously2704 5 років тому

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

  • @KhalidObi
    @KhalidObi 6 років тому

    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.

  • @JoeSparks
    @JoeSparks 6 років тому

    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"

  • @SaeedDesigner7
    @SaeedDesigner7 3 роки тому

    thank yyyyyyyyyyyyyooooooooooooooooooooooouuuuuuuuuuuuuu

  • @luizfernandoalves857
    @luizfernandoalves857 6 років тому

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

    • @ECAbrams
      @ECAbrams  6 років тому

      Obrigado! Gostaria de aproveitar.

  • @goodgamist5113
    @goodgamist5113 4 роки тому +1

    I like how he used if/else for the intro

  • @phendan
    @phendan 6 років тому

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

  • @-________9732
    @-________9732 2 роки тому

    Cool. +++

  • @GammelSami
    @GammelSami 4 роки тому

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

  • @keifferbuckles8976
    @keifferbuckles8976 6 років тому

    more expressions videos!

  • @TheFiXNormal
    @TheFiXNormal 6 років тому

    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  6 років тому +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 6 років тому

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

  • @TheSoul1988
    @TheSoul1988 5 років тому

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

    • @ECAbrams
      @ECAbrams  5 років тому +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}

  • @Feisproductions
    @Feisproductions 6 років тому

    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  6 років тому

      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.

  • @paulscholesisgod
    @paulscholesisgod 6 років тому

    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  6 років тому

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

    • @paulscholesisgod
      @paulscholesisgod 6 років тому

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

  • @anikaschulz6433
    @anikaschulz6433 4 роки тому +1

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

  • @HexenHex-jt6ot
    @HexenHex-jt6ot 2 місяці тому

    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  2 місяці тому +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 3 роки тому

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

    • @ECAbrams
      @ECAbrams  3 роки тому

      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.

  • @alexaraya2018
    @alexaraya2018 2 роки тому

    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  2 роки тому

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

    • @alexaraya2018
      @alexaraya2018 2 роки тому

      @@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?

  • @andriyprvdn1777
    @andriyprvdn1777 4 роки тому

    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  4 роки тому

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

    • @andriyprvdn1777
      @andriyprvdn1777 4 роки тому

      @@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).

  • @karlamata7421
    @karlamata7421 5 років тому

    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  5 років тому +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 5 років тому

      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  5 років тому +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 5 років тому

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

  • @rodgerhunter41
    @rodgerhunter41 5 років тому

    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  5 років тому

      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.

  • @khanlakhno2757
    @khanlakhno2757 6 років тому +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 6 років тому

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

    • @ECAbrams
      @ECAbrams  6 років тому +2

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

  • @hqproductionpotfolio2067
    @hqproductionpotfolio2067 4 роки тому

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

    • @ECAbrams
      @ECAbrams  4 роки тому

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

  • @AaliDGr8
    @AaliDGr8 Місяць тому

    help mere

  • @mediocreape
    @mediocreape Рік тому

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

    • @ECAbrams
      @ECAbrams  Рік тому +1

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

  • @joshbradyvideo1713
    @joshbradyvideo1713 4 роки тому

    "go outside"
    thanks

  • @floppydisk9541
    @floppydisk9541 5 років тому

    After effects is basically adobe flash + Photoshop..

    • @ECAbrams
      @ECAbrams  5 років тому +1

      + illustrator + premiere ;)

  • @brunopoplocker
    @brunopoplocker 5 місяців тому

    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 4 роки тому

    SHOW ME how can i to give you 1000 like?

  • @Berserker_BG
    @Berserker_BG 6 років тому

    expressions..... ugh

    • @Berserker_BG
      @Berserker_BG 6 років тому

      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.

  • @MiasSteenberg
    @MiasSteenberg Рік тому

    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  Рік тому

      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?