487 posts
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Microlancer Beta Tester
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Most Wanted Bounty Winner
  • Slovakia
+1 more
DoubleX says



My new project has over 1000 lines of code (expressions) almost no effects, works super fast, very user friendly and super useful :P Can’t wait to finish and upload! :D
Same here. Right now I just hope we are not creating the same thing :D /mine is full of pie charts and circle graphs, as a new project for envato’s most wanted/
We are :D But why is that a bad thing? I don’t care if i get into Most Wanted or not i just want to make something unique…

That’s not what I ment. For example if you upload your project and it will be approved (before I finish mine) and I’ll see that it’s too similar, I’ll probably have to change/add something. Otherwise mine can be rejected as too similar or you can send a dmca notice (you wouldn’t, would you? :D ) Right now I have 3 types of graphs, every type has additional ways of revealing (that gives about 9 different graphs) and every graph has about 50 customization properties which can be changed in one configuration layer (that’s why tons of expressions). Sounds similar to yours? :D

1802 posts Videohive author & moderator
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Community Moderator
  • Referred more than 2000 users
  • Author had a File in an Envato Bundle
  • Most Wanted Bounty Winner
  • Contributed a Tutorial to a Tuts+ Site
+7 more
Mocarg Volunteer moderator says

Mine has a bunch of properties too but i don’t really think they are THAT similar. But i am not focused on Animations so… we’ll see ;)

345 posts
  • Canada
  • Exclusive Author
  • Has been a member for 3-4 years
  • Contributed a Tutorial to a Tuts+ Site
  • Sold between 10 000 and 50 000 dollars
  • Bought between 100 and 499 items
  • Referred between 10 and 49 users
  • Microlancer Beta Tester
andrenavarre says

Hey guys. Here’s one for you… hope you can help. I’m looking for an expression to make a checkbox that enables/disables a time freeze on a precomp at a specified time… Any ideas?

I have this so far but it starts playing back at the wrong time. The precomp is shifted in the timeline and I think it is using the time from the precomp instead of the comp… so it starts playing late. If that makes sense. I applied this on the Time Remap stopwatch of the layer I want to affect.

c = thisComp.layer("CONTROL").effect("STOPANIMATION")("Checkbox")
if (c==1){
Remap = 0;
}else{
Remap = time
}
4793 posts
  • Community Superstar
  • Elite Author
  • Community Moderator
  • Sold between 100 000 and 250 000 dollars
  • Author had a File in an Envato Bundle
  • Beta Tester
  • Has been a member for 4-5 years
+6 more
felt_tips Volunteer moderator says

Hey guys. Here’s one for you… hope you can help. I’m looking for an expression to make a checkbox that enables/disables a time freeze on a precomp at a specified time… Any ideas?

I have this so far but it starts playing back at the wrong time. The precomp is shifted in the timeline and I think it is using the time from the precomp instead of the comp… so it starts playing late. If that makes sense. I applied this on the Time Remap stopwatch of the layer I want to affect.
c = thisComp.layer("CONTROL").effect("STOPANIMATION")("Checkbox")
if (c==1){
Remap = 0;
}else{
Remap = time
}

Hi André,

So let me understand this… what you want to do is have a footage layer (or maybe even a precomp). You have put a time remap effect onto this layer and you want to control it with a Checkbox on a control layer.

I need to know exactly what you want to achieve and how your controls will work. Is your Checkbox going to change from one state to another? In other words, are you going to keyframe it, or is it just in a general on/off state?

Secondly, how are you expecting the thing to work? At the moment, the layer will sit at 0 while the Checkbox is checked. If it is unchecked, the layer will play with the same time value as the composition.

Initially, I’ll assume that you’re not going to keyframe the Checkbox, or that if you are, that’s not going to have an effect on the point from which the layer plays… that gets a little complicated.

The code below will offset the time that the layer plays from as you shift the layer in the timeline. The variable “time” that you have used is the comp time, so you need to offset that by using sourceTime(time) instead.

c = thisComp.layer("CONTROL").effect("STOPANIMATION")("Checkbox").value;
if(c) 0; else thisLayer.sourceTime(time);

Notes about your code:
Don’t forget the .value after your checkbox link. After Effects will usually manage to assume that you mean the value held in the Checkbox Object and not a reference to the Checkbox Object itself, but not always. If you don’t believe me, put the following on the Text -> Source Text property of a Text layer.

c = thisComp.layer("CONTROL").effect("STOPANIMATION")("Checkbox");
txt = "Without .value, c's type is: " + typeof c + ", it's value is: " + c.toString() + "\nWith .value, c's type is: " + typeof c.value + ", it's value is: " + c.value.toString();

When using a conditional if(something), this works by checking the boolean value of the something inside the brackets. If it evaluates to true, the if block executes, if it evaluates to false, the else block executes. If the type inside the brackets is not a boolean (logical true / false), expression language will change it to one. For example, if it’s a string, then an empty string, ”” will evaluate to false, anything else to true. For a number, 0 evaluates to false, anything else to true. For an object, a null object will evaluate to false, anything else to true… so now try pasting this onto a Text -> Source Text

c = thisComp.layer("CONTROL").effect("STOPANIMATION")("Checkbox").value;
if ( c ) "yes"; else "no";

Make sure the checkbox is set to Off and then remove the .value from the first line. See what I mean? :-)

If you use your .value, then you can write the condition simply as if( c ) otherwise, in effect you’re writing if (true == true) or if (false == true). It may seem petty and your code does work as is, but as your expressions get more complex, it pays to understand what’s going on.

Finally, for compactness if your if block and your else block are each only one line long, you can write it all on one line without the curly braces.

if(condition) x; else y;
Same for loops etc.
while(numStr.length<10) numStr="0"+numStr; //pad with leading zeros

Incidentally, it’s a good idea to avoid the variable names c and p, because if you put ‘em inside brackets, many computers these days will automatically turn them into the copyright or produced symbol… including in these forums.

345 posts
  • Canada
  • Exclusive Author
  • Has been a member for 3-4 years
  • Contributed a Tutorial to a Tuts+ Site
  • Sold between 10 000 and 50 000 dollars
  • Bought between 100 and 499 items
  • Referred between 10 and 49 users
  • Microlancer Beta Tester
andrenavarre says

Wow thanks felt_tips, I really appreciate the time put into your answer. And that text example was super cool. I think I will need to pick up a book to start understanding expressions better, or I should just watch your vimeo channel more often :P . To clear up a few things…

You assumed correctly that this is a simple on/off control with no keyframes (other than the ones that time remap creates when you apply the effect). When the checkbox is not ticked, the pre-comp layer will play normally as if there was no time remap on it. When the checkbox is ticked, I would like the pre-comp to go to a specific time and freeze. (or vice versa, doesn’t really matter for this purpose)

I have an area in the precomp where the animation is still, so I would like to target the stop state of the checkbox to freeze the layer on that still area. In the code I put originally, I had used 0 because on that particular layer the animation was still at 0. But on another layer the still area might be located at 15 seconds, so on that layer I would like the checkbox to make that layer skip to and freeze at the 15 second mark.

So from what I understand this expression is the right way to do my original expression:
k = thisComp.layer("CONTROL").effect("STOPANIMATION")("Checkbox").value;
if(k) 0; else time;
I tried this and it works as expected, without the layer offset And with the layer source offset:
k = thisComp.layer("CONTROL").effect("STOPANIMATION")("Checkbox").value;
if(k) 0; else thisLayer.sourceTime(time);
With this I get an error: Function thisLayer.sourceTime(time) is undefined


So I have some additional questions if you don’t mind… How do I define this? And, what is the proper formatting for time in the expression. For example would skipping to and freezing at 15 seconds look like this?

k = thisComp.layer("CONTROL").effect("STOPANIMATION")("Checkbox").value;
if(k) 15; else thisLayer.sourceTime(time);

What if I wanted to skip to 2 minutes at 15 seconds, or just 30 frames?

EDIT: replaced c with k!

92 posts
  • Argentina
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Microlancer Beta Tester
  • Referred between 50 and 99 users
  • Sold between 10 000 and 50 000 dollars
gfxmotion says

Hi felt,i have a question; how i can animate a mask with expression? example a bar chart controled by a Slider control where i put the number and the animation follow the number ,I don’t know how to do this,i try with the expression of videocopilot but don’t work with mask’s, Would appreciate any help .Thanks

128 posts
  • Bought between 1 and 9 items
  • Most Wanted Bounty Winner
  • Referred between 10 and 49 users
  • Exclusive Author
  • Has been a member for 2-3 years
  • Europe
  • Sold between 50 000 and 100 000 dollars
keybal says

How to use a master Checkbox Control to turn layers on and off (using the value keyword)


I like it and I’m using it, but in that case transparency can be only 0 or 100. That’s not big problem because layer1 can be precomposed and precomposition can contains layer with any opacity value.

That sounds like a lot of extra work. Why not use the value keyword? That gives you the value of the property before the expression.

c =comp("composition_name").layer("layer_with_control").effect("layer1")("Checkbox");
if (c==1){
opacity=value
}else if (c==0){
opacity=0}

...or shorter…
c =comp("composition_name").layer("layer_with_control").effect("layer1")("Checkbox");
c*value;

...or if having the switch on should cause the opacity to be half its original value and having the switch off should cause the opacity to be 15%...

c =comp("composition_name").layer("layer_with_control").effect("layer1")("Checkbox");
c ? value/2 : 15;
Javascript will change the boolean values true and false to 1 or 0, if needs be, depending on what you do with them. Javascript is a loosely typed language and that means it can switch the type of data quite easily from one form to another. See post below for more on Javascript datatypes and the value keyword.

more shorter

comp(“composition_name”).layer(“layer_with_control”).effect(“layer1”)(“Checkbox”)*100;

4793 posts
  • Community Superstar
  • Elite Author
  • Community Moderator
  • Sold between 100 000 and 250 000 dollars
  • Author had a File in an Envato Bundle
  • Beta Tester
  • Has been a member for 4-5 years
+6 more
felt_tips Volunteer moderator says

Hi felt,i have a question; how i can animate a mask with expression? example a bar chart controled by a Slider control where i put the number and the animation follow the number ,I don’t know how to do this,i try with the expression of videocopilot but don’t work with mask’s, Would appreciate any help .Thanks

You can only link a Mask Path to another path with expressions. If you want access to the individual points on the path, you need to use scripting.

To change the shape of the mask dynamically, you could animate a second mask, and then use an expression to pull the value of that mask in to your mask at a certain point in time, using valueAtTime(t)

t = effect("Time")("Slider").value;
thisComp.layer("Black Solid 1").mask("Mask 1").maskPath.valueAtTime(t);

About value and valueAtTime

1692 posts aspire to create - create to inspire
  • Elite Author
  • Author had a File in an Envato Bundle
  • Sold between 50 000 and 100 000 dollars
  • Exclusive Author
  • Bought between 50 and 99 items
  • Referred between 10 and 49 users
  • Germany
+1 more
Creattive says

Hi felt,i have a question; how i can animate a mask with expression? example a bar chart controled by a Slider control where i put the number and the animation follow the number ,I don’t know how to do this,i try with the expression of videocopilot but don’t work with mask’s, Would appreciate any help .Thanks

In this case I would use an alpha matte instead of a mask. You can create a solid and change his height according to your slider value. I’m not sure but probably you have to precomp that solid.

92 posts
  • Argentina
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Microlancer Beta Tester
  • Referred between 50 and 99 users
  • Sold between 10 000 and 50 000 dollars
gfxmotion says

Thanks felt and creattive, i don’t no way but it show this error with the felt expression

a put the expression in the animated path, is this ok or wrong?

anyway i use this in the mask path animated:

control = effect(“Slider Control”)(“Slider”); t = key(numKeys).time; mask(“Mask 1”).maskPath.valueAtTime(t*control/100)

Then i animated a solid an used alpha matte for the mask and work excelent.

Thanks felt and creattive

by
by
by
by
by
by