Getting Started with Scripting in After Effects

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone Sergei here from Ukraine Mediacom thank you all of you primarily on the northern western side of the world I know we're kind of late today but we wanted to try something new we want to go live at 7:00 p.m. instead of what is like 2 3 or 1 o'clock that we usually go live so welcome some of the names that put up here as you can see some of the awesome people home and second my audio is going off one second all right make sure that you guys in here welcome we're going to talk about some scripts or how to create scripts or write them in after fax it's gonna be exciting and by that I mean it might be boring to some of you but that's okay you learn a lot about scripting how awesome they are and just in general how useful scripting can be and I know a lot of you are probably like me you know scared of scripting anytime you you say coding you're gonna be scared of that but that's okay hopefully tonight I'll get rid of that fear for you all right but I'm gonna wait a couple of minutes for everyone to arrive again Ricardo all of you guys welcome whose name I cannot pronounce Felix let me put some other names in here this is just my way of saying hey I noticed you let's see who else is here we have a lot of our - um a lot of different people this is exciting all right I'm gonna wait one more minute and we're gonna dive in because you don't want to miss you know it's it's it's coding once you miss a little bit it's hard to catch up from Mexico awesome we have Felix Cheers Duane I think the wine is from North Carolina somewhere I can remember where Ramesh I can't pronounce half the names I'm sorry I am I can't I have this stuff that's blocking my view so some things I can't see very very well Ahmed undress Calandra dirk I probably should even attempt some of your names but Ricardo welcome all of you guys but anyway I'm about to begin I promise you so again thank you so much for tuning in and by the way just for tuning in I'm not gonna I'm gonna keep the names up I just want to like I give you like a promo code in fact let me do that right now so don't forget for those of you as a reward we reward loyalty so here you go if you guys want to go to Ukraine Mediacom slash I think it's sharp or something like that you'll get ten bucks we do have a script that's two dollars or at least nine dollars so you'll get it for free if you want it so it's just our way of telling you thank you and at the end flat Amir's right here next to me don't we we're gonna give away something right we're gonna give away a promo code which will give 50% off to our expression scores to ten people first ten people or something like that we've never done this before but we won eight yeah you have to stick to the end but we want to encourage or we want to thank you guys for coming in late I know a lot of you are coming home from work and all that stuff so anyway alright let's dive in I think everybody's here we're good everyone can hear me I'm assuming by this point you can Jorge Miami Florida awesome Austria not Australia Denis from Brazil or Denis I'm sorry Seattle India Wilmington I knew yeah and you was North Carolina somewhere Wilmington that's not too far from us we're in Charlotte North Carolina alright okay guys so let's talk about something one second Vladimir just pointed out that I use the old graphic ignore the dates and let me switch transition here we go alright now that we have you can see my screen last time I forgot to switch and a lot of you didn't see my screen so let's talk about coding for a second and just to kind of encourage you a little bit I'm not a coder myself I'm a motion graphics designer I you know that's that's what I did I was a senior motion graphics designer at Fox Sports worked on a lot of cool stuff and coding is not my thing I was terrible in school like I was so terrible that I barely passed you know middle school high school all of that so I'm not the best at math I am NOT that doesn't qualify me very well I'm not speaking very highly of myself right now but I just want to encourage you that hey like you don't need to be great at math you don't need to be super knowledgeable and on top of all of that what I just said by the way I was so terrible at school is the reason why they passed me was because it was a good soccer player teachers were like hey we need to have him on the team so let's pass him and that's how I passed high school and anyway so to encourage you I am not super great at math and all of that jazz but I still got it so I understand expressions I understand coding and so what I'm trying to say you don't have to be smart you don't have to be like super great at math and all of that stuff you just need to know the basics it's like any language you know I'm going to show you basically like intro to JavaScript and then extend script and that's just basically another language it's a language that we speak with computer like we have to understand how to communicate so don't look at it as math I mean math is involved for sure but that's not all that you'll be doing it's just a language a lot of you are foreigners in here so you know what it's like to speak English right now a lot of you didn't speak English at first so it should be easy we have a lot of people coming in I wish I can read a bunch of names I can't pronounce it so I'm going to talk about JavaScript in fact it's gonna be kind of unscripted but I do have a little outline that I want to kind of go go over here so we're gonna be using extant script which is something that's included in Creative Cloud if you have Creative Cloud just go to I believe apps and then at the very bottom at least for me now it might be different for you you have extend script toolkit make sure you download it that's what we're gonna be using and after-effects and extend script and then I'll show you some other resources so the goal of this live session is basically to kind of introduce you to coding and scripting in After Effects but the goal is this not to overwhelm me because I'll be honest with you when I try to learn expressions and by the way I did not know scripting two years ago when I quit Fox Sports I didn't know scripting at all I knew expressions but not very well and when I quit I just dove right into it I realized hey I have two months of savings I need to create some kind of products you know so that I can feed my family because I had this goal that I wanted to do and so I wrote my first script called control it or I think was controller then yeah and then smart react was my second one but I learned it along the way as I was like creating this script so just encourage you I'm not a veteran in this field so it's fairly new to me as well and I got it so it's you don't have to have years of experience you just need to know the basic it's just like driving a car you don't need to know every single detail about a car to drive one you just need to know where the gas is where the steering wheel where the brake and how to switch gears or something like that you know and then the rest as you go on journeys you figure out how to you know change the tire how to do everything else right windshield wipers that'd be nice to know so I'm just saying but the basics is what you need to know the things that can get you rolling and then as you go on this journey of learning coding and stuff you will learn more but if you know the basics you can attach it it's like the skeleton you can attach the meat as you go so I hope this this will help you guys well thank you okay alright so let's get started with JavaScript and by the way I go over all of this stuff in our expression scores but I'm gonna do super fast and you know obviously if you want to learn more you should definitely go to you comedic on slash expressions check out our course and you'll learn more about in-depth JavaScript and then expressions and scripting is something that's not included in the core scripting is something I'm talking to you right now all right JavaScript what is JavaScript and to like I am again I'm not a coder and when I was learning this a lot of people that were teaching me this were like math nerds and they spoke their math language that put me to sleep back in high school you know I I'm not a math guy when I heard someone say you know literals and all that stuff dude that was like a lullaby for me I was I was going to bed you know like you know I was checked out I was thinking should I have ice cream or pretzels I mean you know I was checked out in fact til this day when I do presentations on expressions I can see people just like zoning out so forget it like it's not that hard it's just because they were using this big language big big words and it made it more complicated than it is so javascript is just an object-oriented programming language it's just a language that we talk to computer but it's oriented around the object now if what does that mean around object well it's pretty simple so we have an object-oriented language and then we have procedural so object has to do with an object for example I have a fist so I determined this is a fist right here here's the fist and then I tell it to do something so and then I say punch and then I punch right so the first thing I determine is an object right fist and then I tell it to do something and I'd like some kind of action so his first object and then action right well in a procedural programming language which is not what we're going to be talking about it's the opposite first you create an action you say punch and then you or a kick or something and then you attach it to an object right and then it basically it's just backwards it's a little different approach so because javascript is an object-oriented language the first thing we always determine is an object and it can be a layer it can be a position property it can be anything so that's what we're going to talk about so what what does that mean so for example I want to show you in a second make sure you guys are on everybody's everybody everyone's good right we're still you're still with me I haven't lost you guys talking about expression I talked about coding alright violence okay so because it is object oriented the first thing if we're dealing with we have to determine a thing before we have to let it do something so for example I say layer and then I apply or like a layer property and then rotation so I determine my target let's say rotation property and then and then I tell it to wiggle so the first thing is object and then we will go but just like any objects objects have properties so for example we type something like like let's say ball a ball is an object but then it has properties it's you know it's blue color is blue right and then weights and waist so much and so object properties right and then properties have values so for example object we have properties and properties have values right so we determine we determine the thing and then we tell it to do something a lot of times it's it's written like the action portion of it is called method and then once we determine the object like this we got the value that's like an object you know this whole thing is just object it's a thing right we determine a thing and we say action or it's the same thing as method and methods are written with parentheses like this so then we would say some kind of action so let me let me show you an example with scripting so with scripting you want to make sure that you are in after-effects and I'm gonna create peers and after-effects I'm gonna create a new composition just any composition so I'm gonna write a path to that composition so I'm gonna write like I'm gonna go more in depth here in a second but I know it's basically says app then project and then we're gonna say item and we're gonna say one and I'm gonna tell it to let's say remove as you can see it got rid of it right so that was an object we determine item one would be a composition or whatever that wasn't here right and then I applied action remove so I started with a path I started with a thing an object and then I told it to do something the cool thing about is when you duplicate this action goes with it right so I just want to drive this home that it has to do with object and then we determine you know object could be a property can be a value basically a thing and they would tell it to do something so this is like a quick intro to JavaScript of like the overall without me going into too much detail now so object properties now properties have values for example rotation has a value right it has a value that's a number right like a layer to our layer let's do and by the way like layer name that would be a text what we call string right so it's a double quoted string so like it's a property but it has a value and the value can have five different data types it can be different data types it can be again a var is to create a variable I'm gonna say something like number value right so it's a number it can be a number then I'm gonna say string string value I want to make it the method string is a double-quoted right it's just a string it could be any text right a string when someone says that's something else like threw me off when I was first learning coding it's like what the heck is a string a string is just a string of characters think of it like a string and a bunch of characters that's what they call it basically it's text and the reason why you put them in double quotes or single quotes it doesn't matter you know double a single will work and basically it's our way of telling JavaScript hey whatever we type in double quotes that is just a text it's not a code it's not anything like a keyword it doesn't trigger anything just see it as a text and ignore it right I'm gonna keep it double quotes all right so we have to so far we've gone over two data types we have number string then we have an array and I'm just creating a variable variable just made up write text I'm gonna say array value and it's usually written in square bracket so if you see square brackets it's it that means it's an array right square brackets array and array is just a it's just a one value but it has multiple lists of things it can be it can be numbers right it can be oops it can be a string it can also be an array right it can be any of those and again it can be 11 22 let me zoom out a little bit all right so so far we have three different data types then the fourth one would be so hold on boolean I'm gonna save our boolean and those do value and that's gonna be boolean it's just true or false right it's true or false oops false that's all that is true or false so you see the zero or one and then we have the fourth one or the fifth one is an object now that one you probably won't use that much well let me I'm just gonna say object value an object is written in curly brackets and basically it's the same thing as like a square bracket but the thing about a square bracket only has a value an object has a the name of the property and the value so I can come up with like make up something like name and it can be a string right I'm gonna say let's use one of you guys in here let's see I'm gonna use this name I'm gonna copy from here and in here okay so name then I'm gonna say color let's do blue so again if I'm typing a text you want to put it in double quotes you want to make sure that it's a text you don't want to be a keyword or anything like that and then let's just a number I'm going to say age let's do 22 okay so we went over five different data types we have a number right it can be a number we're used to numbers in a rotation position or rotation opacity that's that's a number that's a one-dimensional number right then we have a string which is just a text think of it it's just a regular text and then we have a rate we're used to array like a position has a two value array like two two-dimensional so it's just an array and then we have boolean true or false and object which similar to an array but it has value however it has a the name of the value and then the value itself okay so let's keep going with this I'm gonna build up on this so we also have alert and basically in an extend script whatever you you know let me go back to toolkit whatever you type in inside of this alert let's say I'm gonna say hi and when I run the script by clicking on this button watch this is just gonna tell it's gonna say script alert hi okay well we can test things in here I can say hey what happens if I alert this variable were here again to set a variable again you put var in front of it and then once you've set a variable then you can use it without putting var var is only four when you first create it okay so it should tell me eleven right I'm I'm asking for the value or the value of this property which is a just variable so when I run it you can see tells me eleven so let's try this one as you can see string it's working now watch what happens if I call up this array if I call it up you can see it gives me this huge list now what if I want to call up only this 33 like if I call this array it gives me the whole list but what if I want to access 33 how would I do that well to do that just remember arrays are written with square brackets open and close square brackets to do that you access because we don't have the name of this value right we can just say well you know this name and then 11 will pop up like this one right here well we have to point to an index value so index meaning where is it at so it starts over here so 0 1 2 3 4 is just a value where it's at in this line it starts with 0 in square brackets index starts with zero so just remember I know it's going to bizarre but it starts with 0 so if I want to get this value I would just say right here at the end of this variable right I would do cool open and close square bracket and in here I would say hey give me the index number 0 1 2 so that would be 2 right so and here would type 2 and when I would play it it would give me 33 so that's how you access arrays now arrays can have a race within an array and then they keep going so for example this thing right here is an array so if I go 0 1 2 3 4 if I call up that one watch what happens so as you can see it gives me two of them which is great but what if I want just a 22 here how would I access that well I hope you're catching on so far so what you do just add another square brackets right here and just say hey we want this value but then we want that one so it's 0 1 so he kind of starts over so if I type 1 it should give me 22 so if I play this it gives me 22 so that's how we access a race no a lot of people get confused with that it within like After Effects right for example if I do new let's do text so let's say position in here or hit P sorry it's so hard to see cuz it's blocking my monitor or my keyboards so as you can see we have two valleys and well that's an array I mean just imagine that there's square brackets in front of it so if you let's say from opacity you want to get this value well that would make sense let's make it something smaller like 20 so we can see it in here because the past he only goes to 100 right so notice if I pick whip to this property right here - this one right here notice it's calling up the 0-1 it's the index zero right it wrote a path to it so it acts it wants this index zero like does that make sense that's how we access things if I wanted this value I would just say remember zero one right it's the same concept so that's where I was saying like if you know the basics you it's just repetitive throughout so when you click away you can see it gives me well let's make it 10 it should give me 10 there you go 10 so I hope that's making sense you're on the Mac let me let me kind of switch back to the chat make sure you guys are paying attention position is an array all right does anyone know okay people are not finding the extent script there's a link at the bottom this video click on that you should find there should be a listed at the bottom of it you should find it alright everyone's ok duplication is as a value okay okay I'm gonna keep going here because I can get lost for these comments but you guys are okay so far everyone's good alright I'm gonna keep going so we talked about arrays or yeah now let's talk about boolean for a second that boolean has to do with true or false like it's it just gives you it it's the same thing it's just a keyword for a number for example if I use a method called number if I type true and if I alert it shift on this my bet alert let's see what it would give me so it would say hey what true is actually number and if I run this it will tell me what number it is it's actually one it's the same thing as 1 or let's do false it's 0 so again false is 0 2 is 1 but if you want to be more colorful with your words you might want to use true or false but you can get away with 1 or 0 all right so that's what boolean is and you would use it in if-else statement you can say if what say if let's say I'm gonna create a variable in here I'm gonna call it a just variable hey you're gonna be let's do 3 all right and then I'm gonna do if else statement I must say if a equals by the way double equals is actually equals in JavaScript because we use equals single one to set a variable right so you can't use it again so we use double equals two it actually means equals okay so I'm gonna say if a equals two three right I want for it to alert I'm gonna stay alert I just we're gonna say three and then I'm gonna say if it's not three else I'm gonna tell to let's do I'm alert and I'll say something like not three not the mama all right then so right now a is three so when I run this it says it's three because this condition right here is true and it went to the first statement but if I change this to one anything other than three then it would do this well I was gonna somehow connect this to true and true and false okay well we use that usually with the check box you know you can say like if a is true like if check box is true if it's checked right then you can say true then it goes go over here and say and tell us that it's true right and it's the same concept true and if it's false well you basically basically we use that with check box you know that's our something that's on/off on/off that's what true or false boolean means on or off anyway clear as mud I hope you guys are keeping up all right in the last data type that I want to talk to you quickly about and by the way all that I go over in better detail in our course but we're live we're doing it and that's what your that's what we're getting right now but the last one is object value basically it's an object now the way we access an object is pretty simple we just say object value let me just copy this and then make sure we put alerts because we want to see what we're typing here all right so we if we alert this let's see what happens it just tells me it's an object well that's great but then if we want to access the name I would just say period name and then it would tell me the name or if I wanted to get the caller I would say caller right and then would give me the color now that's one way to do it you can also do square brackets for this if you want to call up if you want to type it in like if you want to type it in like this name if you want to type in your property right then it would tell you the name and the reason why you want to do that because sometimes in scripts you want to insert something either through like through a script or something like that for example I can use another alert thing called prompt and then I'm gonna say type property here or something like that and if I run this it would just say type property here and I can say hey age I'm gonna type age and then it would take this age and insert it in here and if I type it boom it tells me 22 anyway so with that I just want to show you these are the the five things the five data types that you're gonna be dealing with and the rest is just you know if else statement for loops all of that jazz that's what you're gonna be dealing with and if you want to learn more about again all of this you can either take our course you can media Commons expressions or you can go online and just go nuts with the JavaScript sites a good one is actually I believe it's right here it's this one w3schools you can learn more on your own but obviously you just have to kind of learn how to do it within extend script so it will take some time okay now let's go back over here now let's create something something new I just want to quickly go over this stuff but I want to tell you about reflection objects so for example we can find out what kind of properties we can apply it to things or methods right for example if I have this object I'm gonna say Alerts objects and we're gonna call this up I know let's say I don't know these properties I just know the name of the object I wanna know what kind of properties this object has how can I find out right well I can easily do that I can just say reflect properties and when I type when I run it it'll tell me has name color page so then I'm like oh cool it has named as one of them so I'm going to say name and then boom it gives me the name right but then you can also find out what kind of actions right we determine our object we determine our thing that we you know remember JavaScript is object oriented so now we want to do something with it so I'm saying hey name is a string it's a string right it's a text so I want to know what kind of string methods it has right so you can use the same thing reflection instead of properties I'm gonna type reflect instead of properties we're gonna say methods and again methods it's the same thing as actions right so when you run it you can see all of these methods right for example now we're pointing to the name it's a name right here I see something like to lowercase to uppercase so that's a method that I can use and I'm gonna get rid of this I'm like okay to uppercase I'm gonna you know uppercase and again methods have parentheses like this so when I run it notice my name is all caps if I say to lowercase and you'll see them all lowercase it doesn't matter how you type it in here you can control it now the website that I was telling you about it has all of these things you know what a string is now you know what a number is what an array is well you can actually go to learn JavaScript here and you can kind of go over what methods strings have like strings have methods you can kind of see all of them like right in here you can kind of go over but if you go all the way to the bottom you can see a whole list of them so now that you know what those data types are right you can actually see what kind of string methods you can apply right for example we the one we just used was called to uppercase right here to uppercase you can click on it and you can read more about it like hey here's how you apply it here's how you know and and it'll give you some examples so you can kind of this is me telling you the basics and you can go and like in other words I don't need to learn all of that I just need to know where to go to find out more so you can find out what kind of methods methods strings have then you can find out what kind of methods like an array has so let's see what would is an array here all right so these are the methods for arrays and you can kind of go through all of them and kind of click and see what you can do with it the same thing for other things and you know number it has some methods you know some properties methods to fixed all of that stuff you can find out on your own and and then go from there so a lot of times when I code something if I if I want to do something I'm like okay what do I need to get there and a lot of times I'll find the methods that I need to get there and it's just it's a lot of times it's determining the object and then telling it to do something and then maybe doing some math okay how are we doing so far valued Siam yep okay so let me write let's kind of I'm not sure how we do on time so we've been added for 30 minutes and I know how I'm throwing a lot at you guys but hang in there because now we're gonna do something practical so let's do this let's write let's write a script to create a new composition and within that composition let's create a new text and within the text let's create like something like a set a position maybe opacity animation something like that let's let's see how we can make that happen so this is where we talk about practical stuff and this is where I introduce you to another great resource and it's this one right here so the link again to both of these are at the bottom of this video in the description so Docs dot a and hence our comm it's a great resource so in here we kind of learn more about how After Effects or how extend script works within After Effects you know how to code it basically how to do scripting and After Effects and this thing is perfect illustration of how it looks in After Effects so this is like the illustration of the hierarchy of things in After Effects how after facts works so the first thing you see is application right we have system files all that stuff but the one that we are interested in is application then we have settings or project right project that would be like the project window and then we have items those are like composition folders images all that stuff as you can see it's comp items footage and folder items and then with income items we have layers properties so that's like the hierarchy of things so let me point like so we have app project items right that's how we get to compositions right and for example let me create a new comp in here I'm just gonna create a new composition make sure you switch to After Effects whatever version that you are in and I'm gonna call this name I'm gonna say let's go hey one of you guys Jamal let's do this one let me copy your whole username alright let's see ok so that's the name so I can access the name from here let me write write an address so the first thing I'm gonna do I'm gonna do alert because we want to pop it up right and in here I'm gonna say app period now there are scripts that help you to get the address to whatever property or I call it address but the path to the property but I'm gonna show you how to do it manually so you understand how it works ok so first is app remember it's app then project and items right so then I'm gonna say in here let's go back alright so we're going to app period that we're gonna go into project period and then we gonna go to item and in here we're gonna call index so item is actually it's actually a method as you notice by these two parentheses it's a method that calls up another object right in this case it's looking for an index number like of whatever we have in here so this is like an end this is like an array whatever you put in here it's like an array so we have only one thing so we just want index number one now index four methods it actually starts at one if you see square brackets it starts at 0 so one okay and then I'm gonna say period name so it's gonna go all the way to this this composition and then we're gonna select a property called name right and again you can reflect methods or property so you can you can find out what kind of properties it has like this right it lists you all the properties it has but we want a property called name so no that one so I'm gonna say name say if I run the script watch as it tells me the name of this composition that's cool well if I know the name I can do something with it so I'm gonna say okay name since you are you know I'm gonna tell you to be something else so within it's a it's a text right it's a string so we have to when we assign something to a property or whatever you want to make sure that the data types match so we're dealing with a string we're gonna give it a string so that's important that you do that okay so we're gonna replace it for this all right so I'm gonna replace it for this right this name Christian Oh Christian I'm not sure how to say it properly so now if I run this watch this boom it changed it so as you can see that's how we changed something so let me show you how we can use a resource to create something in other words let me show you how to not use my brain at all to create something to kind of show you how I arrived there with the resources because the reason what honestly this is why I wanted to do it alive so you can see my struggles you can see how I work because a lot of times you kind of see the polished stuff but I want you to see how I arrived there alright so let me get rid of all of this and let's do this we're gonna go to this great resource right so in here we're gonna create a new composition so you can see items you know what items are it has to do with composition you know comp items folders so that's the documentation for those then you know what layers are you can see what what you can do with those you know what properties are and render queue and all these other things so I'm gonna show you how you can work this to create your first script alright so we need to create a new composition so I'm going to go over here I know that composition is an item okay so I'm like okay it's got to be in here somewhere okay item collection object so that's what I want and remember even in here so they have methods you know what methods are it's just action right so I'm gonna click on a method and in here we have a method called add comp I'm going to click on it and in here we have basically they give you an example of how it should look it's that simple and then on top of that for each thing they help you out here and they describe it to you this is all amazing this is right so then I would copy this right selected copy it and I'm gonna go to extend script and I'm just gonna paste it in here okay and let me kind of scale it down all right so the first the first thing that it's asking me let me zoom out a bit more so app project items right basically we got to the root of items you know and then we've got over there were using a method remember parentheses looks familiar it's a method we're gonna tell it to add a a compa create a new comp right and in here it kind of tells us what we need to replace so if you run it like this no nothing will happen because you need to come up with a name remember name as a string is a text so you have to treat it like a text so I'm gonna say let's let's get somebody else's name in here and T productions and by the way down at the bottom in the description area I I placed like an only one youtube channel for resources and it's an T productions you'll see it at the bottom of this video in the descriptions and this guy is a wisp and I'm honored that he's on here so nate is his name he's a super awesome if you're watching this right now and you want to learn more because that dude is like way out there so I highly recommend that you subscribe to his channel I mean highly recommend and he's been talking to him we're friends Nate right and he's a great guy and you're gonna love his tutorials definitely check him out so add comp we're gonna come up with the name and I'm gonna put NT productions in here so anti productions and then with we're gonna say something like 1920 by 1080 so it's a text right pixel aspect we're gonna say one duration how long do you wanted to be it's usually in seconds so I'm gonna say 10 seconds frame rates 29.97 so after you did all of that then you can run it you can say run and as you can see anti productions a new composition right if we go into here you can see - a 1920 by 1080 we have frame rates 10 seconds right here so that's how easy it is to create it okay and I'm actually going to give it I'm gonna do this I'm gonna say variable you're going the new comp so I'm just gonna I'm gonna tell it to be new comp okay so now that we know how to create a new comp how do we create a new text layer how do we create that so let's keep going I'm gonna say variable new let's do well let's do this so we have composition let's do a new text layer or a new layer it doesn't need to be text but it's gonna be text variables are just made up English doesn't mean anything until you assign something so I'm gonna say equals you're gonna equal two and then we're gonna pick up where we left off we're gonna say all right since we're ready create a new composition then we're gonna say alright let's go back to the cheat sheet let's go back to the resource here and let's see how we can use it how we can utilize it so now that we moved away from items we've determined you know we create a new composition let's go to layers but we're dealing with layers how can we use this awesome resource so layer collection object in here and in here we have methods actions right and let's see add text awesome that's exactly what I need here so in here we're gonna already have it for us right project since we already created item we're gonna pick it up from here alright we don't need to undo all of that I mean you can if you want to put alright so in here I'm just gonna say boom make sure you get rid of double period here so layers add text and right here it's asking for source text so we're gonna say hey it's gonna be a string I'm gonna do this it's going to be a string so we need to treat it as a string so we're gonna say layer the text is gonna be and let's come up with somebody else Dwain let's do Dewayne Walters we're gonna put him in here alright that's gonna be that and let's let's see what happens let's run this so we have NT productions we have a new text and there you have it alright well then let's do this I want to play with position like I want for this text to be positioned about here let's say like 150 and 1000 so I can remember it something like that okay so then I would say let's do this new layer we already have that one declared so that's gonna be I'm just going to pick it up from there I'm gonna say new layer let's do this so we're gonna go into position mmm okay and then for position value I'm gonna set value and I'll tell it to be well it's not a string it's gonna be this time it's an array remember so you have to speak the same data type right if it's an array you have to speak the same in other words I have to have a value that's two-dimensional so square brackets and in here I'm going to say what was it again 150 and 1000 okay so let's see what happens so let's get rid of all of this jazz and let's run it so let's run this boom and if you hit position there you go so that's how we did that okay that sounds cool let's add an expression to it so we're gonna say new we can copy basically this paste it instead of set the value so set value if if you want to set like a value for a property right but we're gonna say expression and then we're going to tell it to be expression is text right so we want to treat it as text we're gonna say wiggle and we're gonna say something like - maybe 50 all right let's see what happens and again this is live so in my break alright so we have this let's run it Oh wrong one this one so it create a new a new composition and then if you preview this it is wiggling so let's go to position you can see expression has been applied so it's working next let's fade that in so we need to set the opacity right okay so we're gonna have to create a keyframe so how do we do that let's go back to the cheat sheet so let's go back to an amazing resource we have here and in here we're gonna go to properties and let's see what they have here so methods let's see we need something to add a keyframe so oh there you go add key from a DS so that that's probably good let's copy this and in here let's go back to extend script so in here we're gonna paste this right now and then instead of position so we're gonna we're gonna go to the beginning over here we're gonna say new layer we want opacity right and we want to set a key at time so time is a number so we're gonna set a keyframe at zero second mark so zero okay and then we want to duplicate that again because we want another keyframe set at one second mark okay so now if I run this boom it created this okay let's see so let's press T to reveal the opacity as you can see we have our keys however they're not really they're just created but they're not really doing anything so we need to set some values for them so how do we add values to them all right let's keep going so let's go back to our cheat sheet so again this is just me doing it live and let's see so what do we have here the set value may be like set key let's go over here somewhere it's gotta be in here somewhere so set value at key that looks like it might be it let's copy this and let's go back to here and we're going to paste that in here and then for opacity so we're gonna do this I'm gonna copy opacity just that path and then we're gonna say set value at key and which key do we want and remember with the effects or methods index starts with 1 so it's 1 so the first key would be 1 okay and we won the value to be zero because first keyframe we went to be 0 right and then by the way semicolon is just our way of telling JavaScript you know that's a period and code language or said we're done with the statement go to the next one so I'm going to copy this and then paste it and we want key number two my keyframe the second keyframe right and for that one we want it to be 100 all right so let's run this let's see what happens and really I hope you were catching on here it's kind of similar to right like doing actions in Photoshop it's just it's just us going through the steps and that's how it happens you know nothing crazy is just understanding the basics and knowing how to apply it and knowing the tools like an amazing website I just showed you so let's run this so created that one okay so now let's see play this yeah it's working as you can see first key is set at 0 second one is 100 and boom and it's wiggling so position property is working and yeah it's awesome but here's the thing you're like alright this is great like why why do I need this like I can just do it well I mean obviously you can run it multiple times and create a bunch of different but you can actually take this and convert it into what we call function it might be not a proper way of saying this but for us motion designers it's kind of like pre comping it's it's grouping an action and then you trigger it later right so for example you just type function and then you name the function so we can name it let's name it something like let's see whoo-hoo we haven't used here this person I'm just copying somebody from the chat all right Fiona and in here we're just gonna say alright Fiona is gonna be a new action or a new function and then anything starting with this code block and by the way code block is just us grouping everything into one value right and so starting from code block or curly brackets left one and all the way to the right one so we're closing it so we're basically saying Fiona you're gonna be everything between these two in fact I'm gonna select this press tab to kind of inter indent that first layer so you can kind of visually see better what's going on so now if I run this code nothing will happen watch this because now we have to trigger it before it was just running it now we have to say alright we want to run this Fiona so boom and now when I run it it creates it but the cool thing about this let me undo this the cool thing about this now you can create variables for Fiona for example I can create a variable for comp name so I can say comp name it's a totally made-up variable doesn't mean anything and then instead of having NT productions which is a great website you you just replace it for a variable so now when Fiona you can just create because it assumes the first key right or the first variable it would be the name of your composition then you can say something like let's see you this person whose name I cannot pronounce but so when I type this this will be it'll basically put it it's the same thing as company and it will replace it it will basically put this in there I hope that's making sense so now when I run it there we go create a composition named Alex I'm sure I'm sure I'm butchering this name and then the rest works works well right let's see we can we can keep going with this so then we can say instead of company I mean we'll have company let's do also text or a list you as a text you okay will do layer name okay and instead of Duane so add text actually we didn't do that so let's do this we also need to do this we're gonna say new layer dot name we want it to be that layer name okay so let's see what happens we'll just call it layer name so I'm talking about this right here right now it says Duane but it should say layer name but it will still have Duane so layer name all right let's see if this works the beautiful thing about doing stuff live you get to see my floss alright here we go nope it didn't work so what did I do wrong here newly I misspelled layer all right let's try this again yeah it's working out so let me get rid of all of this so watch this boom and as you can see later name that's what we did here name okay so let's keep going here let's do title will say title okay it's a new title and instead of it being Dwayne we're just going to replace him for title okay so we have cup name cup a layer name and then title and here I can say something like euchre mediacom / expressions I know it's a block and now if I get rid of this these lights are hot do you feel this what whoa the heat all right here we go and let's see so now we have layer name and you can either come / expressions so I hope again you see the importance of functions how awesome they are you can create different things and call them up at any time I gotta get some water minutes these lights are hot whoa okay so again you might be wondering I mean that's great you know but how can this be even how can this be useful well before we go any further let me do this I do have a list I covered most of this stuff but let me let me keep going here so if I run this watch this - if I press ctrl Z and undo it watch what happens it goes through every stage and that's not that's not practical so to avoid that we use a we use thing called begin undo group and again you can you can label this group you can label something like code doesn't really matter and then you want to tell it where you want it when you press control Z when you kind of basically say app and write undo group let's see if this works it looks like it looks right but let's see if it works so now if I run the script okay I didn't do something right so let's go back to my source all right so what I do here if I if I can't remember something I just do undo group and searching and there you go make sure to type it right so where the heck is control I'm do there you go so begin undo group I'm not sure why I didn't type right I'll just copy it go back over here oh I guess yeah sorry and then you would label it code I guess you don't need to put period I know I put period all right so let's run this again let's see what happens all right so it worked so now watch this if I press ctrl-z it goes back to where I was so it's a definitely good good thing to know that's special if you wrote like a loan text and your loan code and you rent it it's like thousands of steps can you imagine undoing everything yeah that can take you forever okay so what else can I go over and I don't know if we have time what do we what do we look at okay we have time let's talk about for loops but before I do that let me let me see how you guys are doing came in late I just wanted to shout out okay how is everybody doing okay well this is so awesome and NC productions which is made good a good dude he's actually on here answering questions so Nate man thanks thanks for being here man by the way again if you are not subscribed to NT productions you are missing out I don't know how many times I've used his tutorials to create even the scripts that I work on you know a lot of times you hit some stuff and you like crap how do you do this and then someone like and T productions come around and you get to you know learn some stuff from him and you get to plug it into your own script and it's awesome I've been using his binary converting images to binary code I use it still today NC productions man thanks thanks so much for that script I've run it all the time I convert my images into a code and then I get to use it in my scripts which is awesome okay let me take some water here and we're gonna cover one more thing it's basically for loops I'm gonna talk about that all right let's keep going here so for loops basically for loops I mean my own English words I would say it's just a way we loop things would make things run multiple times right in the way it works like this is say for and then you define condition and then you say well let's do open curly brackets and we close it right anything we type basically it's gonna run whatever's between the curly brackets right and in our case oops it would be this but you can't do that with one line okay so in here here's what I'm gonna do so let's do this I'm gonna create a variable called again just create a variable you just put var and then we're gonna say something like comp names okay I'm totally making stuff up right now so I'm gonna tell it to be an array and I'll list some names in here so we're gonna do let's do like three names so three names and let me copy some of you guys Ricardo welcome in let me copy your name and put it in here let's do two more we used a lot of you here so I'm not sure how to say this name but that's why I'm copying and one more a lot of you have low names like me alright so we have these three names okay so in here for for loops we're gonna just we're gonna say I which is just a variable may not variable it can be anything but a lot of people go with I we're gonna tell it to be is 0 at the beginning so it's going to start with a value 0 and then we're gonna say I we're gonna define condition just like an if-else statement we're say we're gonna say run this code as long as I is less than we're gonna say comp name names that length which that length is a property of how many names we have in here right it's gonna give me 3 so that's good well so I'm gonna say as long as we have three names run it three times right and then I can say I plus plus which is increase incrementally so just go one two three four it's the same thing as saying I plus equals one right that's the same thing or if you want to skip to or whatever it's the same thing but it's just plus plus it's increase incrementally basically by one and no instead of this name here I'm going to do this I'm going to say comp names and remember square brackets that's how we access which one we want right we want zero but instead of which one we want I'm going to say I and what I is in the first loop will be 0 and the second loop will be 1 in this you know it'll do like 3 loops right because we have 3 names so it will access with with each loop will create a comp with this one the next one the next one at least that's my thinking let's see if it actually does that so nothing is in here let's run the script let's see what happens yeah thank god it worked as you can see created one two three compositions and different names but they have the same content the same stuff which is great okay so then we can create another one we can say variable comp well as do layer names and for this one or Yahoo's you layer names for this one we can do just and quick I'll just say let's do one two three and I'll just say a b c and the same concept here we would just say a set of names we're going to say layer names and then square brackets we're gonna say i which is a number that changes with each loop at first at zero because we set it to zero then it's going to increase it by one right this incrementally increase so then it's gonna be two three and it will access each one so i hope i'm making sense but anyway let me undo that it should work now yeah undo remember we set this up to where it will go completely to where you started so now when we run this each one will have a layer see right be a so it's working well all right then here we can do the same thing for text but you get the idea but let me do this again just so you know what I'm talking about so we'll do title and in here we're gonna say let's do the same concept it's so hard to type when you you know this thing is blocking my keyboard all right so we're gonna say something like let's copy some of your names again Christian Christian Christian I think maybe Dwayne it's so good that I have these names to work with there that's great and Jamal okay so now if I run this well I want to make sure that copy this replace it for that and again we access an array by doing the square brackets and we're going to type I so if I run this as you can see we have Jamal Dwayne and cristiana anyway that is basically it I mean if you if you're done with this you can go file and save it as and you can save it as let's go to well desktop I'm just gonna dis save you the desktop we can just say test you know just name it whatever and then you can just go to file and scripts and you can say run script file and just point to that file and that's how you run it so what is it it took me like an hour and has it been yeah it's like an hour about an hour to explain all of this and I'm sure to a lot of you it's just it's a lot of information if you're not used to this but it's really not that difficult it's really just understanding different data types how its structured and how to use amazing resources like this website and that website you can find out what kind of actions you can apply right but you know if it's a string okay you like all right if it's if it's a text what kind of methods actions I can use and then you could do that so these two resources highly recommend you I mean you've seen me how how I used it you can see how valuable they are and yeah that is it and I think I'm gonna call it quits right now but how are you guys doing how was it did did you get it or I'm sure maybe some of you will have to kind of watch it again which again you will be able to watch it again we'll make it available for at least 24 hours so you can watch us again and if you want to learn more about expressions I highly recommend that you take our course at UK Mediacom / expressions and for coming into this live broadcast you automatically get to use a $10 promo code live and let me do this so let me show you this promo code as you can see promo code live you can use it 10 bucks sweet I mean you don't even have to purchase anything you can just go to your community um slash shop and we do have control it which is the script that I wrote learning scripting and you can download it for free it's 9 bucks so it's just a gift for us to you to give to you for coming in like late at night or 7 o'clock or whatever it is wherever you are so thank you for being here we reward loyalty and Vlad do we have the promo code okay what's the code okay so the promo code it's only available to ten people if you want to learn expressions you can get it for 50% off if you type you Commedia and it's only available to ten people you can learn how to create module lower third I mean check it out you definitely should check out how to do that stuff basically it's a lot of the stuff that I kind of went over with like the JavaScript but it's basically showing you how to do that in after-effects how to create a module or third to where everything adjust and all of that stuff we have like 13 hours of content you should definitely check it out and thank you guys for supporting us and something else euchre media is the promo code you UK are a media only 10 people so 10 people after that it expires so you can only use it 10 times I will watch it again Ricarda awesome you can use VAR and let's can you do it in a you can use it while let's in in the new expression engine I'm not sure if extend script is up to date and you can correct me on see productions I didn't just stuck with var but I'll have to go over like what what a let is and constant all these different ways of setting X variables yeah Christian create a complete course on scripting along with NC productions you know I've been I've been talking to Nate I'm like Nate we got a team up to do something so if Nate is cool with it out I'd love to do something like that just for the fact that I can learn more from Nate Nate is like a heavyweight he's like a wiz you should check out his Nate can you put up the link to I don't know if you can do that on youtube but he's got like all these awesome scripts that he created you should definitely check out very very helpful Thanks so yeah let me know what's the feedback have you guys was this helpful to you was it did it shine some light on how to create stuff and you know how to write your first script and I haven't even gone over like the UI side of things and all that stuff which is a whole different ballgame but but this right here just if you have to create 20 comps or something like that you can quickly do that like writing a code and it can boom created it will save you time or if you have to send them to render queue you can do like this and just again using those the same resources I shared with you so knowing that skill will speed up your workflow and it's not as scary if a guy who barely passed high school can do it and speaks English what is my fourth language then you can do it as well so this should inspire you for sure newbie to scripting like me okay Viktor did you watch the whole thing from the beginning I'm curious to see if if if you were able to catch something but yeah I you know I'm not again I've only been doing scripting for two years but I understand the foundation the fundamentals of JavaScript which is which is the core of everything if you understand how JavaScript works it's just a matter of learning how that looks in after-effects but JavaScript again it's object-oriented language its objects properties and methods you know at first it's an object then it's a method and you know different data types there are five of them and we talked about that and you should definitely watch it was helpful to me I know coding part for WordPress but scripting awesome Duane um I'm glad it's yes okay great okay all right guys once again if you want to purchase our expressions course it's 50% off for the next 24 or next ten people ten people and it's you Commedia promo codes 50% off if you want a little more go for it and by the way I am wearing action VFX t-shirt which is which is an amazing group of people action VFX they actually are located in Johnson City where I went to school and they're awesome we're friends with them this is not a paid thing this is just me giving them a shout out they're just amazing people so action the effects you guys are awesome I don't know if your own here and by the way we do have a mentoring group on Facebook that you should definitely join you see the links at the bottom of this video I'm not sure if it's if it's there you comedic a'm slash community you should definitely join our community a lot of you guys are that's where a lot of heavyweights I'm not sure if NC productions is on it Nate are you on it if you're not you should definitely on it but we have people like Nate who are you know eager to teach people and they enjoy it just like me I enjoy teaching it's a lot of fun for me and there you can go get teach somebody else or be mentored or you know it's it's an amazing place you should definitely check it out you're missing out if you're not you're the average of five people that you hang out with and if you're not hanging out with people like NT productions then you're missing out let's see what we have here your gray was doing huh so hopefully you understand next time turn up turn up hold on one second it's hard to see it's so far away is it for Amanda hope I'm pronouncing it right there you go now isn't it awesome Victoire again Victor thank you for being here NC productions Duane from Fernanda there was M because R and n were kind of close together Duane sadly sadly telex thank you guys Christian from believe you're in Brazil right that's one country haven't been one of many but I'd love to go there one day Kenneth thank you for being here Ricardo Fiona German not sure if I'm pronouncing it correctly and yeah all of you guys thank you for the comments thank you for all the love and all the support again if you wanna to promo codes live if you want to get ten bucks and purchase something or even if you want to get a free script for nine bucks which we'll cover it just promo code live and if you want to get a 50% off first ten people what was the UK media program here yeah all right guys again thank you so much for being here I know it's kind of late a lot of you are coming in from work but thank you for being here we appreciate you but until next time my name is Sergei brock Nevsky and this is Yuka Mediacom you
Info
Channel: ukramedia
Views: 50,846
Rating: undefined out of 5
Keywords: scripting, coding, scripting in after effects, scripting in adobe after effects, extendscript, using extendscript, getting started, how to, tutorial, getting started with scripting, getting started with coding, getting started with coding in after effects, getting started with scripting in after effects
Id: suHCaob5-KE
Channel Id: undefined
Length: 68min 36sec (4116 seconds)
Published: Mon Jul 29 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.