Quantcast
Channel: Adobe Community : Popular Discussions - After Effects Expressions
Viewing all 47983 articles
Browse latest View live

Number Counting Expression with $ - Understanding how to set stop points

$
0
0

Hello, I'm using an expression I found on: Dan Ebberts's Expressioneering Design Guide which has saved me quiet a bit of frustration since I needed to have a comma and a custom character at the end of my counting numbers. But I have a simple question that I can't quite get out of the page's instructions and I'm hoping someone here could direct me.


Issue: The numbers are counting for the first 4 seconds - or whatever I change it too, but I don't understand how to set my number stop points. ie, I want to go from 0 to 1,800 pause at a specific point for several seconds and then count up to 6,500 pause again and count up and so on. So the part I'm not understanding is, how to start the count and stop on a number and then start the count again. I've set key frames for where I want those numbers to be on the timeline in the 'Source Text' which Dan's page references but this isn't working. Thoughts? Direction??? Expression is below and I've attached a reference image of my timeline. Many thanks for any direction you can provide!


Expression:

numDecimals = 0;

commas = true;

dollarSign = true;

beginCount = 0;

endCount = 17000;

dur = 4;

 

 

t = time - inPoint;

s = linear (t, 0, dur, beginCount, endCount).toFixed(numDecimals);

 

prefix = "";

if (s[0] == "-"){

  prefix = "-";

  s = s.substr(1);

}

if(dollarSign) prefix += "±";

 

if (commas){

  decimals = "";

  if (numDecimals > 0){

    decimals = s.substr(-(numDecimals + 1));

    s = s.substr(0,s.length - (numDecimals + 1));

  }

  outStr = s.substr(-s.length, (s.length-1)%3 +1);

  for (i = Math.floor((s.length-1)/3); i > 0; i--){

    outStr += "," + s.substr(-i*3,3);

  }

  outStr + decimals + prefix;

}else{

  prefix + s;

}

ref.jpg


Parenting Layer Positions - Can Variations Be Added?

$
0
0

If I parent one layer to a child layer, then the child layer will move exactly the same as the parent layer. If the parent layer moves 200 pixels to the right, then the child layer will move 200 pixels to the right.

 

Is there a way to vary the way the child layer moves? Say, a lesser percentage of pixels?

 

See below. The parent layer is the right pupil, and the child layer is the left pupil. Both pupils are centered, and look like they're in the right place.

Screen Shot 2015-01-05 at 10.45.10 PM.png

The right pupil parent layer moves to the right, and the child layer left pupil moves the same distance. It's starting to look wrong.

Screen Shot 2015-01-05 at 10.45.37 PM.png

The right pupil parent layer moves all the way to the edge of the eyeball. Now the child layer pupil has left the eye socket, and seems kind of other-worldly.

Screen Shot 2015-01-05 at 10.46.06 PM.png

 

Is there a way to tell the child layer to somehow move less than the parent layer? Say, 70% or 80% of the distance of the parent?

"global" function in expressions

$
0
0

Hi guys,

 

I'm looking for something very basic with expressions but can't seem to find it. I want to define a function and use that function inside ~100 or so layers. At the moment I'm typing a couple of lines of code inside each expression layer to drive the position of each layer which is insane of course. I just want to define one function (and define it only once):

 

function getPosition(null1,null2,offset){

     ...stuff..

     return position

}

 

And in my comp, use that function everywhere to drive the position attribute for example:

 

getPosition("null5",null6",0)

 

Writing that function inside each expression is a bit daft of course but I can't seem to find a way to define such a function to use throughout my comp. Could anyone point me in the right direction? Thanks!

After Effects Font Expression

$
0
0

Dear AE expressionators,

 

Concrete: I am making a template whereas the user can change the text font and that it will automatically update this to the hole template.

 

For example, see the picture.

So everything I change in the above text layer the under text layer transforms with it. But if I change the font it doesn't.

Does after effects use a different expression for automatically changing a font?

 

I would really appreciate your help!!!

 

I'm using after effects CS6

Decimal numbers in expression

$
0
0

Hi! I have created a counter on a text layer that counts length in increments om 40 cm controlled by a slider, I added this expression to the source text property and it works great except for the decimals. 

 

t = effect("Slider Control")("Slider")

x = Math.round(t/.4)*.4+0.0001

 

 

x = x + " Meter"

 

 

x.toString().replace(".", ",");

 

 

It now counts 0,001 Meter.... 0,4001 Meter... 0,8001 Meter.... 1,2001 Meter..... but i want it to only show 2 decimals: 0,40..0,80..1,20..1,60...

 

I added the +0.0001 in Math.round to get decimals at the whole numbers. I.e. 4 Meter is now 4,0001 Meter... But how do I remove the last two digits? Or is there another way to always show 2 decimals? I need the counter speed to be controlled over time and masking is a problem since the font I use is not monospaced.

 

Thank you.

About JSX importing in AfterEffects 15.1

$
0
0

I've been importing json files with stringified javascript and evaled them in my comps to reuse scripts.

Since updating to 15.1 I get an error when I try to import them and as the error tells me, I renamed them to jsx files and it works fine.

 

I would like to know the specification of the imported jsx files. (Not the extended script jsx)

Are they just basically the same as imported JSON only with different file extensions?

I was hoping if I can write javascript directly without the hassle of having to stringify it everytime.

Are there any documents related to this?

timer expression

$
0
0

Hi, this is the 1st time i post here & i'm newbie in using expressions i was trying to set out an expression that make my timer follow my progress bar like this

MbbX5Xl.png

sp = thisComp.layer("timer");

ep = thisComp.layer("timer"));

t = comp("Music").marker.key("Music End").time;

val = linear(time, 0, t, sp[0], ep[0]);

[val, sp[1]];

 

but i keep getting

unknown.png

Time Remap Expression

$
0
0

I'm trying to do trigger a keyframe for a timeremap using an expression as follows, but after I put in the expression the output goes black:

 

 

  • Did a timeremap on the precomp.
  • Put in two keyframes. One where I need the comp to start, second where it ends.
  • Then I used the following expression:

        clockStart = parseInt(comp("main").layer(5).text.sourceText.value); 

 

        t = linear(time,0,clockStart+1,0,key(1).value+time);
        valueAtTime(t);

 

clockStart here is basically where I want the composition to trigger In. So my first keyframe.value is 14, Second keyframe.value is 20. If my clockStart is 10. At the start of the play the value of the timeRemap for this layer/comp is set to 14 (first keyframe value). Then when it plays, and clockStart reaches 10 then the timeremap start's counting in from 14 onwards until the second key frame (value is 20). This seems to work as I want but the issue is the output goes black I don't have any output while the expression is enabled on the time Remap. I tried looking for other properties like opacity but all are set properly and opacity is 100per. THe moment I remove the expression I have output on it. What can be wrong with this expression ?


sourceRectAtTime expression

$
0
0

Hi,

 

I’m trying to get a sourceRectAtTime expression to work out the longest text box length and use that to create a box behind.

However no matter how I change the s= value, I can’t seem to work it out.

 

Any help would be greatly appreciated!

Current expression below:

 

s = thisComp.layer("TOP LINE TEXT LONGER STILLER") = if((thisComp.layer("TOP LINE TEXT LONGER STILLER")>thisComp.layer("TEXT 2”)) else thisComp.layer("TEXT 2”);

 

x = s.sourceRectAtTime(time-s.inPoint,true).width;

 

y = height = 104;

 

[x , y]

 

Thanks!

Why the matchname like (Pseudo/jof683d967ELQ-0003) appearing in expressions

$
0
0

I have come across an expression like this

a = effect("Transform 1")("ADBE Geometry2-0001");

p = effect("Transform 1")("ADBE Geometry2-0002");

x = p[0]+(a[0]-thisComp.width/2);

y = p[1]+(a[1]-thisComp.height/2);

seedRandom(thisComp.layer("Setting").effect("Shake")("Pseudo/jof683d967ELQ-0003"))

w=value-wiggle(6,thisComp.layer("Setting").effect("Shake")("Pseudo/jof683d967ELQ-0002"));

[x,y]+w;

 

You can refer to this screenshot

Scrennshot ae.png - Google Drive

 

 

Could not able to understand this pseudo part

How to get the footage's current frame number in expression?

$
0
0

There are 2 layers.One is text layer,one is sequence layer.

Footage has begun from the 20th frame.

Therefore, the number of composition's current frame number and footage's frame number has shifted.

 

I want to show footage's frame number in text layer . not composition's frame number.

How to get the footage's current frame number in expression?

 

 

Tatsuya

Fill Color Controller to change between colors overtime

$
0
0

Hi All,

 

I'm using CS6 AE..

 

I have created a clapometer style animation that uses a colour controller and value/numbers controller to animate the hand from left to right of a semi circle. As the hand moves (by a value slider) the layer underneath fills and I would like the color to go from yellow to red via multiple colors.

 

So far I have this code on my fill layer

 

l=thisComp.layer("Fill color controllers");

i=1;

colors=[];

try {

while(l.effect(i)) {

if (l.effect(i)(1).name=="Color") {

colors.push(l.effect(i)(1).value);

}

i++;

}

} catch (e) {}

if (colors.length) {

r=Math.floor(random(colors.length));

colors[r];

} else {

}

 

And a fill color controller layer with 5 different color expression controls. At the moment the code cycles through them randomly, but I would like cycle through the list. I know there are other ways I could do this but I am trying to improve my expression knowledge and hope someone can help me!

 

Cheers!

Add a delay to an expression

$
0
0

So I have an expression that controls the opacity something along the lines of

 

if(other layer >50) opacity(100) else opacity(0)

 

is there a way I could stick a delay in the else part of my expression. Logically I want the opacity to go to 0 but i want it to wait a second before it does. Would it be something like

 

else opacity(0) delay(.1)

 

i don't want to delay the whole expression just the part that makes the opacity go to 0

 

any help would be great

how to edit keyframe values through expressions using global values

$
0
0

hello,

 

I would like to make the values of keyframes dependent on "point controls" that I generated.

 

Is it possible to give values of the point controls to a specific keyframe?

 

different point control values would change different keyframes of the same parameter and same layer.

 

thank you!

erg

How do I create a conditional statement with multiple values

$
0
0

I'm trying to create the following conditional statement:

 

if(thisComp.layer("Controls").effect("First Slider Control")("Slider")==61

&&

if(thisComp.layer("Controls").effect("Second Slider Control")("Slider")==3

&&

if(thisComp.layer("Controls").effect("Third Slider Control")("Slider")==24)100 else 0;

 

I'm applying the above expression to another layer's transparency property.

 

First of all, is there a way to simplify the above expression?

 

And now to my main question:

 

Is there a way to include multiple values into the expression above?

 

For example:

 

I want to be able to have the layers transparency be 100 if the "Second Slider Control" value is either "1,2,3,4 or 5" and "Third Slider Control" value is either 24,30,32 or 38.

 

Here are some notes:

 

If the "First Slider Control" value is 61

and

If the "Second Slider Control" value is either 1, 2, 3, 4 or 5

and

If the "Third Slider Control" value is either 24, 30, 32 or 38

Then the layer transparency is set to 100

Any other value on any of the 3 slider controls will set the layer transparency to 0

 

I've been trying to do this and can't seem to figure out the right way to do it.


Slider only scale X

$
0
0

Hi I got a slidercontrol = xScale

and a shape named = BAR

 

What expression would only scale the X

 

Regards

Flemming

SourceRectAtTime ERROR

time code and expressions HELP

$
0
0

Hello,

My name is Dalal and I need help in my project, in my project there is a hologram control panel and in that panel is a clock from sec to hours, I followed a tutorial on youtube of how to animate and code sec and mins but not hours I need help in coding hours the time starts from 7:30 AM to 5 PM.

 

Here is what I coded:

 

slider=effect("Slider Control")("Slider");

sec = slider%60;

min = Math.floor(slider/60);

 

function addZero(n){

if(n<10) return"0"+n else return n;

}

if(slider>0) {

addZero(min)+":"+ addZero(sec)

}else{

"00:00"

}

Switching Opacity of Layers with a Randomized Slider Controller

$
0
0

I've got thisComp.numLayers - 1 layers in my composition, plus a slider control on a null object placed above those layers. The slider control has this expression:

 

num = thisComp.numLayers;
seedRandom(1881);
Math.floor(random(2, num + 1));

 

And each other layer's opacity property has this expression:

 

ctrl = thisComp.layer("controller").effect("layer")("Slider");

if (ctrl == thisLayer.index) 100;
else 0;

 

The ideal situation is that one layer's opacity is triggered per frame. I know that sounds strange and visually upsetting out of context, but after a few time displacement effects and echos and yadayadayada, it'll look how I want it.

 

And the result is that at least one layer is usually being triggered every frame. But many frames are triggering two layers at once, often a frame whose index is nowhere near any of the slider's most recent past and following results, and sometimes no layers are being triggered even though the slider's value is clearly within bounds and pointing to a specific layer. Which is strange. It could be a syntax issue. I understand AE isn't quite as lax as other JS compilers out there. If I just need to put brackets around the if/else outputs, I'll just do a simple face palm and move on.I should clarify I tried this, and it did not help.

 

So I wanted to document this. I'll likely find a fix or workaround as I always do, but I never ask the community questions like this and feel the answers to these seemingly specialized questions could benefit someone in the future.

Can sourceRectAtTime be used for a single word in a text string?

$
0
0

I'd like to isolate a single word or a few words, to obtain their sourceRectAtTime props. The result should not interfere with their original position(s).

Possible with sourceRectAtTime or is there a better/alternative solution?

Viewing all 47983 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>