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

"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!


Fade audio with expressions

$
0
0

Ok, I've taken an epxression for automactically fading opacity (which worked wonderfully) and tried to modify it to fade audio the same way.  Now, I get an error that says "After Effects warning: Expression Disabled. Error at line 0 in property....  expression result must be of dimension 2 not 1."

 

Here is the tweaked expression:

 

fadeTime = 30;

audio.audioLevelsMin = -50;

audio.audioLevelsMax = 0;

layerDuration = outPoint - inPoint;

singleFrame = thisComp.frameDuration;

 

animateIn = linear(time, inPoint, (inPoint + framesToTime(fadeTime)), audio.audioLevelsMin, audio.audioLevelsMax);

animateOut = linear(time, (outPoint - framesToTime(fadeTime+1)), (outPoint-singleFrame), audio.audioLevelsMax, audio.audioLevelsMin);

 

if(time < (layerDuration/2+inPoint)){

animateIn;

}else{

animateOut;

}

 

Now, opacity is a linear, 1 dimensional characteristic.  Why did that work and the updated expression for audio cause an error?

Expression error using checkbox control

$
0
0

I'm trying, for the first time, to create an expression that controls a value depending on whether or not a keyed checkbox is on.  This is my code.

 


x = comp("overlay grain").layer("frame").transform.position;

 

If (effect("Frame Stutter")("Checkbox") == true)
{
    value = x + wiggle(25,5);
}
Else
{
    value = value + wiggle(25,5);
}

 


When I run this, I get the error:

 


After Effects warning: Function If is undefined
Expression disabled.

 

Error occurred at line 3.
Comp: 'main'
Layer: 1 ('Date Stamp')
Property: 'Position'

 


I have been racking my brain over what the problem is.  I have used If/Else statements in the past successfully and I know that there is just something very simple that I am missing.  I have also tried using "== 1" instead of "== true", but I got the same result.

 

Help please.

Getting global coordinates from parented local coords.

$
0
0

I have a mocha tracked null. I child another null thats slightly offset in XY. Now the child's coordinates are relative to the parent. But how can I get the child's true position in the comp?

 

This seems too easy:

 

thisComp.layer("parentNULL").transform.position + thisComp.layer("childNULL").transform.position

 

Am I missing something?

Is it possible to confine expressions to specific keyframes?

$
0
0

I am definitely a beginner when it comes to expressions.

I am currently using a "bounce" expression on the position parameter of some objects as they come on screen. However, the next time they change positions, I don't want them to bounce. Every time a motion tween ends in a static position, the position expression gets applied and the stuff is moving around.

I'd like to be able to keyframe the expression so that it worked only when on the keyframes that it makes sense to affect.

 

amp = .05;

freq = 1;

decay = 7;


n = 0;

if (numKeys > 0)

{

     n = nearestKey(time).index;

     if (key(n).time > time)

     {

          n--;

     }

}



if (n == 0)

{

     t = 0;

}

else

{

     t = time - key(n).time;

}



if (n > 0)

{

     v = velocityAtTime(key(n).time - thisComp.frameDuration/10);

     value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);

}

else

{

value

}

 

I got this script from somewhere online. The only thing I know how to manipulate are the initial values of amp, freq, and decay.

How to wiggle a layer on odd frame numbers.

$
0
0

Hello. I am using AE CS6. Now I am trying to make an cartoon animation, and now I am trying to wiggle some layers' position.

But I don't want to wiggle the layers on every frame. I want to wiggle them only on odd frame numbers.

I mean, I want to wiggle them on frame 1,3,5,7,,,,, but don't want to wiggle on frame 0,2,4,6,,,,,  .

I am not familiar with expressions, but is it possible to make such a expression? I don't know what to write in "If" clause of wiggle expression.

Please give me your advice. Thank you in advance.

Is there a way of grabbing the name of a shape layer without referring to it specifically?

$
0
0

similar to 'thisLayer.name', is there a way of being able to grab the name of a shape layer without referring to it specifically?

 

I'm wanting something like 'thisShape.name' rather than having to define it as content("this shape name")

 

Any help with this would be greatly appreciated!

 

thanks

Loop Out Stop expression

$
0
0

I was wondering if it's possible to create a stop/smooth ending to a LoopOut expression on Rotation and Position keyframes.   I am currently using OSX 10.9.3 After Effects CS6 and I have tried a couple of things that haven't worked for me.

 

adding a checkbox expression control to the layer and an expression for loopOut()

 

if (effect("Checkbox Control")("Checkbox")==true){

loopOut();

}else{

value;

}

 

 

loopOutDuration(“cycle”,2)

 

Unfortunately neither of these seems to work.  I was wondering if someone had a solution they have come across.

 

Thanks very much

 

Ira


Why do I need an expression to Scale X/Y independently?

$
0
0

Scale is what... the 2nd or 3rd most used form of motion?

 

So why do I need an expression (and a **** tonne of googling) to find out how to link the X or Y scale of an object independently to a slider?

 

Why doesn't each of the two scales (X/Y) have the ability to simply be pickWhipped to a Slider or any other form of controller?

 

Would make sense, surely. And save newcomers a world of time.

 

UPDATE: Part 2 of this question:

 

If this works:

[temp, temp]

 

then why can't this work?

[temp, value]

 

Would this also make too much sense?


Surely it would be far more logical than this nonsense:

[temp[0], value[1]]


Visualising audio as analog VU meter

$
0
0

Hey,

 

So I'm kinda new to AE, but I know enough to get around so that's clear now.

So I'm starting up a YouTube music channel and I'm trying to find out how to represent audio as an analog VU meter.

The image I am working with is below, and as you can see, it has 7 empty VU meters which I want to represent each track I have (7).

Does anyone know of how such thing would be done?

 

Thanks,

James.

 

background-VU.png

clamp a wiggle expression

$
0
0

How do I go about clamping a wiggle expression?

 

I am using the mosaic effect with a wiggle expression on it. The only thing is that I never want the number to become 1, only 2 or higher as with 1 the mosaic effect make vertical lines that I don't want.

 

Cheers

AE: Expressions - Animate position change of each layer from top to bottom?

$
0
0

So I just started using AE this week. I'm a super newbie. Any assistance you give me is appreciated, but should also be dumbed down so I can follow it.

 

I'm making these dungeon tutorial videos for Final Fantasy XV and I started working on the first project.
I spent about an hour making 1 table and animating it, and I will obviously be using this same table for every dungeon tutorial, but rather than copying and pasting every layer and making new compositions and yadda yadda, I started looking into expressions today to achieve this (I'm assuming simple) effect that I'm going for.

 

So essentially, picture this in your brain.
The dungeon tutorial is something you'd see in a strategy guide. The first 30 seconds of the video feature: The Treasure you will find in the Dungeon, the Monsters you will fight in the Dungeon, the name of the Dungeon, the Dungeon Level, etc. And each of these things I will need to be able to customize for future dungeon tutorials, so naturally I don't want to spend 8 years editing these things keyframe by keyframe, that's just madness. I'd rather play the game.


I have 1 Composition named "Treasure Overview"
And this Composition is made up of 14 Pre-Comps.
Each Pre-Comp is basically a row in a table.

 

So picture the table as such:

(Pre-Comp 1) TREASURESALE VALUE
(PC2) Earth Gemstone1500
(PC3) Beautiful Bottle120
(PC4) Strong Bone200
(PC5) Rough Scales250


etc...

Each Pre-Comp is comprised of 4 layers:
- text: TREASURE
- text: SALE VALUE
- background for Treasure
- background for Sale Value

 

Super easy, nothing fancy

 

For simplicity sake, let's say that the first row of the table is at position (0,0)
That would put row 2 at (0,1)
row 3 at (0,2)
row 4 at (0,3) etc

 

I want to animate the rows in the table using expressions. So that the rows basically unfold vertically.
They all start at (0,0) and end up in their final position (0,1) (0,2) (0,3), etc

 

SO FAR, the only thing I've managed to do is create an expression on each layer so that the Y position is offset by 38 (the height of each pre-comp)

 

y = thisComp.layer(index-1).transform.position[1];

[0, y+38];

 

this sets the y value for each row in the final position that it's supposed to be in, but I can't get it to animate in succession.
I've tried looking up tutorials using valueAtTime()

 

and that works... but not really. I'm clearly missing something, because I can't seem to specify both the POSITION AND THE "DELAY in animation"
every time i follow these tutorials I get errors upon errors when I try to adjust the tutorials to fit what im trying to do

 


I need something like (pseduo-code incoming)

 

thisLayer.transform.position[0, y+38].valueAtTime(time + 5);

 

Something that will let me specify the start and end position and the delay in animation
using an expression

offset corner pin with different x y offset values

$
0
0

Hello!

 

Suppose you have a keyframed corner pin effect. Is there a way to extend a pin point (example: top left corner point) with different offset values for X and Y using expressions?

I tried everything, but I can't get it to work: the extended point doesn't stick with the right proportion over the animation.

This expression is one of the many i applied without any success. It works only if offset X and Y values are equal (ex.

Any suggestion? Thanks.

 

 

// CALCULATE CENTER COORDINATES

TL = effect("Pin")(1);

TR = effect("Pin")(2);

DL= effect("Pin")(3);

DR = effect("Pin")(4);

var vertices_x = [];

var vertices_y = [];

var min_x = Math.min(TL[0],TR[0],DL[0],DR[0]);

var max_x = Math.max(TL[0],TR[0],DL[0],DR[0]);

var min_y = Math.min(TL[1],TR[1],DL[1],DR[1]);

var max_y = Math.max(TL[1],TR[1],DL[1],DR[1]);

var mid_x = (min_x + max_x) / 2;

var mid_y = (min_y + max_y) / 2;

center = [mid_x,mid_y];

 

// OFFSET

offset = [20,50];

 

// TOP LEFT VECTOR

vector = normalize(TL - center);

 

// CALCULATE NEW TOP LEFT

x = TL[0] + * vector[0] * offset[0];

y = TL[1] + * vector[1] * offset[1];

[x,y]

loopOut() script won't loop keyframes. Why?

$
0
0

Hello. I am using AE cs6 win version.

Right now I am trying to loop key frames using loopOut() expression, but it won't loop.

Please see this video.

 

 

Moving of The pale blue square is what I want, but if I use loopOut() expression to make such moving, it makes this green square movement. This green square has only 2 hold interpolation keyf rames on x position, and I just use default loopOut() expression. Seems green square's key frame 2 is ignored after first loop by loop expression.

Do you know why? Thank you in advance.

Expressions depending on program language? WTF??

$
0
0

How insanely stupid is this? I am working on After Effects in English. Now i got an AEP from a collegue who uses AE in german. The particular project uses a lot of expressions connecting to "Controls for Expressions". An when i open that project in my AE, i get dozens of error messages because all the controls and properties are beeing translated into english while the handlers of the expressions aren't.

 

Is there any possibility for me to fix this without changing almost 50 expressions in 15 comps and without changing my AE to german (because this would mean to reinstall the complete Creative Suite -- another fact that makes no sense)

 

thany you very much

u


Code help - number counter by incremental rate

$
0
0

Hey there,

 

I've creating a number counter that counts up from 0 to 24,776 using point control that includes commas. I researched existing codes and found the one below one using this link. Here is my existing code for the source text expression:

v = effect ("Point Control")("Point");

s = "" + Math.round(v[0]);

 

if (s.length > 3 && s.length < 7)

s.substr(0, s.length -3) + "," + s.substr(-3)

 

else if (s.length >= 7 && s.length < 10)

s.substr(0, s.length -6) + "," + s.substr(-6, 3)  +"," + s.substr(-3)

 

else if (s.length >= 10 && s.length < 13)

s.substr(0, s.length -9) + "," + s.substr(-9, 3) + "," + s.substr(-6, 3)  +"," + s.substr(-3)

 

Now, I'd like to alter the code so I can change what increment the numbers grow by. Can someone build that code and explain it?

How to get relative position of layer in larger precomp.

$
0
0

The Setup:

 

Comp 1 is 2000x3000 pixels. Comp 1 contains Layer X that is positioned at 1750,1250. (or whatever)

 

I pull Comp 1 into Comp 2 which is 800x600. I scale and move Comp 1 inside Comp 2 by an arbitrary amount.

 

How can I determine Layer X's position using Comp 2's coordinate space?

Opacity expression question

$
0
0

Hello I`m looking for an expression that randomly (within parameters)  switches a layers opacity on or off, but crucially does so by fading up and down ( X seconds) rather than just on or off ( which I have an expression for). Can anyone help, thanks  John McGeoch

opacity of an image 0 or 100 tied to voice volume keyframes?

$
0
0

This is probably going to be stupidly easy, but I'm relatively new to AE, and I'm stumped.

 

So what I'm trying to do is make a little speaker symbol (similar to what you see in your taskbar) that reacts to audio.
For the quieter stuff, only one bar becomes visible, and for the louder/max stuff two/all three become visible.

 

And I mostly have it. But the different bars have a range of opacity. I just want them on/off within that range.

 

For example, the opacity of this .png is pick-whipped to a slider on the audio track. The slider has this expression on it: linear(value,2.6,4.9,0,100)

 

Works pretty good, but the opacity needs to be an on/off kind of thing, and not a 0-100% kind of thing.

 

Here's a screenshot:

Imgur: The most awesome images on the Internet

 

I've been trying to learn some if/then expressions, some checkbox stuff, and some 0 else 100 stuff... but correctly implementing any of them for this specific task has, so far, been unsuccessful.

 

Thank you for your help.

 

Message was edited by: derick white, typos

Controlling tangents of a shape layer (cc 2018)

$
0
0

Figured it would be a lot of discussion re: the new scripting functionality of paths, but I can't find anything on this topic.

 

Is it possible to control the in and out tangents of an existing object by reference say the width of a shape layer? In other words: can I control the shape layer objects tangents other than just using the values on other objects.

 

I'm trying to define the tangent value this way:

myPath = thisComp.layer("Shape Layer 1").content("Shape 1").content("Path 1").path

myPath.inTangents()[2] = [120,50]

(the values are not referencing anything, I know!)

I get the 'object of type array found where a Property is needed' warning.

 

What is the correct way of doing this? Can't find any example in the expression reference help.

Viewing all 47983 articles
Browse latest View live


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