In previous topics, we've covered some basic ways to define or modify parameters using After Effects expressions. But let's do something a little more complex to start harnessing the practical side of expressions.
What we discussed in prior topics was how to create some values based on time, or index. But, these values were always absolute. There is nothing telling After Effects that "if this value reaches a certain point, then do something else". This is exactly what if/else is for.
Consider the following example. Put this on the position of, perhaps, a type layer.
xPos= time * 200 ; yPos = position[1] ;
[ xPos , yPos ]
If you've been reading the other blogs, this should mostly make sense, but let's review.
We declare a variable "xPos" to be equal to time multipied by 200. Remember, time is the current time of the AE playback head or "CTI". As the time in the comp time becomes greater, the value of the term time increases. Therefore, as time in the comp progresses, the text moves in a postive direction in the X axis.
Next, we provide AE with the values that we want our position to be. Unlike parameters like opacity that are defined by one number, position is defined by multiple numbers (x and y, in this case), which we call an array. When we provide AE with the values for an array, we need to use this kind of format:
For a 2d layer:
[ x , y ]
or for a 3D layer:
[ x , y, z ]
So in our example, [ xPos , yPos ] is providing the x and y values.
xPos =========> is X
yPos =========> is Y
position[1] is just like value[1] that we've covered before, just specific to position. So, position[1] is the exisiting Y value that you can modify.
What were we talking about? Oh yeah, if/else.
What if we wanted this movement to stop at, say, a value 200 in the x axis?
In plain English (as that is what I speak), I would say:
"If the position of my object is less than 200, then keep moving, otherwise stop".
The way we say this in expressions is like this:
if (condition){ result1 }else{ result2 }
AE will not even look at anything beyond line result1 if the condition is true. When condition is not true, AE will ONLY be concerned with result2. It's always going to look at result1 OR result2, never both with if/else.
So, for this to work with our example, this would be the code:
xPos= time * 200 ;
yPos = value[1] ;
if (xPos < 200){
[xPos, yPos];
}else{ [200 , yPos ] ; }
Let's take this apart. First we declare our variables:
xPos= time * 200 ; yPos = value[1] ;
Then we have:
if (xPos < 200){
which means: If the condition of xPos being less than 200 is true... then the result is:
[ xPos , yPos ];
However, if it is not true..}else{
Then set the x position equal to 200, and y position to yPos:
[200 , yPos ] ;
Then close the brace:
}
As xPos increases, our type's x position increases. When xPos is over 200, the type's x-position becomes fixed at 200.
You might be a little overwhelmed by a lot of things that look unfamiliar, like these { and } braces. When using an if/else condition, we have two possible results: if the condition is true do result1, else do result2. Both of the results must be enclosed with these { } braces, even if on different lines. We can right this several ways, like:
if (condition)
{result1}
else
{result2}
But, the first way of writing it is more common, as result1 and result2 are not limited to one line of code, they could be a complex computation, and becomes easier to view if the brackets are pushed out of the way. ALWAYS REMEMBER.. never put one brace { without closing it with another brace }.
Give that a try and check back for more expression topics!
This blog is fantastic! I'm actually understanding and retaining the information presented here.
ReplyDeleteIf you packaged this into a complete book, I'd buy it in a heartbeat.
Mmmmmaaaybe just maybe some video training is coming.
ReplyDeleteThank you so much! This is the most well written stuff sbout expressions I have seen so far on any site!
ReplyDeleteThis really is a well written site. Even the user comments teach you something! I am planning on taking college courses in javascript programming, but as of right now am just a beginner. In the realm of amatures, there is no other tool quite so concise, informative, and correct as this blog! (Believe me. I checked) Thanks for all your work. :)
ReplyDeleteI love your site! You will be in our prayers and thoughts! Nice and informative post on this topic thanks for sharing with us.Thank you
ReplyDeleteLogo Maker
Very nice article! nice to reading this post!!
ReplyDeletebest essay writing service company
Very useful post actually your shared here.I am sure your post will help students more in their study. It helped me lot. Thank you.
ReplyDeletebest essay writing service
Thanks for posting the useful information to my vision. This is excellent information.
ReplyDeleteBest BCA College in Noida
myTectra Placement Portal is a Web based portal brings Potentials Employers and myTectra Candidates on a common platform for placement assistance
ReplyDeleteIt's the best time to make some plans for the long run and it is time
ReplyDeleteto be happy.
instagram sign up
tutuapp apk ios
Thanks for such a great article here. I was searching for something like this for quite a long time and at last I’ve found it on your blog. It was definitely interesting for me to read about their market situation nowadays. Well written article Thank You for Sharing with Us pmp training in chennai | pmp training institute in chennai | pmp training centers in chennai| pmp training in velachery | pmp training near me | pmp training courses online | project management courses in chennai
ReplyDeleteBig Data Hadoop Training in Bhopal
ReplyDeleteFullStack Training in Bhopal
PHP Training in Bhopal
Python Training in Bhopal
Machine Learning Training in Bhopal
Digital Marketing Training in Bhopal
Unsur permainan Poker Uang Asli telah lama hadir dan mendunia lebih-lebih di kalangan para pecinta judi, masih banyak yang belum paham bagaimana sistem bermain pada game tersebut.
ReplyDeleteasikqq
http://dewaqqq.club/
http://sumoqq.today/
interqq
pionpoker
bandar ceme terpercaya
betgratis
paito warna terlengkap
syair sgp
This comment has been removed by the author.
ReplyDeleteشركه الصفرات من اضمن الشركات بالرياض على الاطلاق من حيث العماله وادوات واجهزه التنظيف ومواد العزل وادوات كشف التسريبات تمتلك الشركه افض انواع المنظفات المستورده شركه الصفرات فى خدمتك وخدمه اسرتك فى اى
ReplyDelete.وقت كل ما عليك هو التواصل مع مندوبنا عبر الارقام الموضحه سيصك فريق العمل المتخصص بافضل المعدات لأداء الخدمه المطلوبه
شركة الصفرات لتنظيف المنازل بالرياض
شركة الصفرات لعزل الاسطح بالرياض
شركة الصفرات لتنظيف المجالس بالرياض
شركة الصفرات لتنظيف السجاد بالرياض
شركة الصفرات لنقل الاثاث بالرياض
شركة الصفرات لمكافحة الحشرات بالرياض
شركة الصفرات لكشف التسربات بالرياض
شركة الصفرات لتنظيف المسابح بالرياض
شركة الصفرات لتنظيف الخزانات بالرياض
شركة الصفرات لتسليك المجاري بالرياض
شركة نقل اثاث بابها
ReplyDeleteكيف تختار أثاث مكتبي
عند القيام بعملية اختيار أثاث مكتبي يجب أن تعرف بعض الخطوات التي تساعدك في الوصول لأعلى كفاءة تناسب ذوقك ومكانك ومن هذة الخطوات
شركة نقل اثاث بابها
قياس المساحة المطلوبة للمكان : فالمساحة عامل مهم جدا عند اختيارك لأثاث مكتبي منظم ومرتب وهذة الخطوة مهمة حتى لا يكون المكان مزدحم والأثاث مزدحم ويكون غير مرتب مع بعضه البعض من هنا نقول أن الرسم التخطيطى المبدأى للمكان يساعدك فى عوامل كثيرة ,وذلك لأنك تكون على دراية كاملة بمقاسات الأثاث الذى ستقوم بوضعه فى مكتبك ,أو شركتك
شركة نقل اثاث بابها
الألوان :تعتبر الألوان من أهم الخطوات التي يجب اتباعها عند اختيار أثاث مكتبي وذلك لعدة عوامل من أهمها تنسيق الأثاث مع الدهانات التي تكون بالمكتب وذلك لأظهاره بشكل مناسب ولائق ومن هنا نقول أن تنسيق الألوان الدهان مع الأثاث يعتبر من الأساسيات شركة نقل عفش بابها,ولايمكن إهمال هذه الخطوة ,وعليك بالألوان البسيطة لأنها تكون عصرية وتظهر الملامح الكاملة للديكورات التى قمت بعملها فى مكتبك شركة نقل عفش بابها
Oh my goodness! an amazing article dude. Thank you However I am experiencing issue with ur rss. Don’t know why Unable to subscribe to it. Is there anyone getting identical rss problem? Anyone who knows kindly respond. Thnkx
ReplyDeleteiMuslim.co.id
Fasion Muslim
Muslim Beauty
Very nice post, i certainly love this website, keep on it
ReplyDeleteLibur.co
Ayo Liburan
Tempat Liburan
You should take part in a contest for one of the best blogs on the web. I will recommend this site!
ReplyDeleteJogja
Wisata Jogja
Yogyakarta
You made some decent points there. I looked on the internet for the issue and found most individuals will go along with with your website.
ReplyDeleteProvenexpert.com
Information
Click Here
Visit Web
Impressive writing. You have the power to keep the reader occupied with your quality content and style of writing. I encourage you to write more.
ReplyDeleteBCom 3rd Year Admit Card