FORUMS: list search recent posts

Modifying Ease Wizz expression with a slider controller

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Adam levine
Modifying Ease Wizz expression with a slider controller
on Dec 5, 2015 at 8:39:29 pm
Last Edited By Adam levine on Dec 6, 2015 at 7:32:28 am

I've a layer with 2 position keyframes and I gave ease wizz inoutexpo expression. But I want to change the value of second keyrame by a slider controller. so I changed the expression like this.

// Ease and Wizz 2.0.3 : inOutExpo : All keyframes
// Ian Haigh (http://ianhaigh.com/easeandwizz/)
// Last built: 2012-10-11T16:37:31+11:00

// some defaults
var p = 0.8; // period for elastic
var a = 50; // amplitude for elastic
var s = 1.70158; // overshoot amount for "back"


function easeandwizz_inOutExpo(t, b, c, d) {
if (t==0) return b;
if (t==d) return b+c;
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
}


function easeAndWizz() {
var n = 0;
if (numKeys > 0) {
n = nearestKey(time).index;
if (key(n).time > time) { n-- }
}

try {
var key1 = key(n);
var key2 = key(n+1);
} catch(e) {
return null;
}

// determine how many dimensions the keyframes need
var dim = 1; // It's gotta have at least ONE dimension
try {
key(1)[1];
dim = 2;
key(1)[2];
dim = 3;
} catch(e) {}

t = time - key1.time;
d = key2.time - key1.time;

sX = key1[0];
eX = key2[0] - key1[0];

if (dim >= 2) {
sY = key1[1];
eY = key2[1] - key1[1];

if (dim >= 3) {
sZ = key1[2];
eZ = key2[2] - key1[2];
}
}

if ((time < key1.time) || (time > key2.time)) {
return value;
} else {
val1 = easeandwizz_inOutExpo(t, sX, eX, d, a, p, s);
switch (dim) {
case 1:
return val1;
break;
case 2:
val2 = easeandwizz_inOutExpo(t, sY, eY, d, a, p, s);
return [val1, val2];
break;
case 3:
val2 = easeandwizz_inOutExpo(t, sY, eY, d, a, p, s);
val3 = easeandwizz_inOutExpo(t, sZ, eZ, d, a, p, s);
return [val1, val2, val3];
break;
default:
return null;
}
}
}

(easeAndWizz() || value);


changed to :

sX = key1[0];
eX = effect("Slider Control")(1) - key1[0];


It works ok. But problem is when the key2 time comes it change back to key2 original value. Please can anyone give me an Idea. I hope Master Dan'll give me a help on this. :D
sorry for my English.


Return to posts index

Kalle Kannisto
Re: Modifying Ease Wizz expression with a slider controller
on Dec 6, 2015 at 6:07:57 pm
Last Edited By Kalle Kannisto on Dec 6, 2015 at 6:12:42 pm

To me it seems that the following should work

sX = key1[0];
key2 += [effect("Slider Control")(1),0,0]
eX = key2[0] - key1[0];


You may need to change the number of dimensions on the second line if the keyframe is not 3-dimensional.


Return to posts index

Adam levine
Re: Modifying Ease Wizz expression with a slider controller
on Dec 7, 2015 at 7:13:29 am

Thank you Kalle Kannisto for your reply. But It doesn't work. It give an error.

" After Effects warning: Class 'Array' has no property or method named 'time' "

And there's no problem in my second line. It works ok. But the problem is when the time indicator come to the key 2 (mean original keyframe) value go back to the keyframe's original X position value.


Return to posts index


Kalle Kannisto
Re: Modifying Ease Wizz expression with a slider controller
on Dec 7, 2015 at 8:36:30 am
Last Edited By Kalle Kannisto on Dec 8, 2015 at 2:45:58 pm

Alright, I discovered that the data returned by key(index) is an object with value, time and index properties.

The problem is that Key2 becomes Key1 the moment you come to it on the timeline, so somehow you'd need to take that into account.

Do you have more than two position keyframes on the layer, i.e. is the problem just with a single frame, or do you need to continue to a third keyframe beyond keyframe 2?

If you are only using two keyframes, you could pick the keyframes by their index number instead of nearest keyframe.


Return to posts index

Adam levine
Re: Modifying Ease Wizz expression with a slider controller
on Dec 10, 2015 at 8:27:45 am

yeah! I'm using only two keyframes.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]