Page 1 of 1

easing remapped time between markers

Posted: November 16th, 2008, 5:10 am
by antoska
First of all sorry for my poor experience about expressions.

I have done a modification of Dan Ebberts's expression "Trigerring animation with markers) for use the time of the markers from another comp layer but I am always getting an error "this property has no keyframe number xx"
What I am doing wrong?. Is there any way the expression to stop looking for more markers than the layer has got. Thanks in advance


action =comp("time_remap").layer("White Solid 1");

n = 0;

if (marker.numKeys > 0){

n = marker.nearestKey(time).index;



if (marker.key(n).time >= time){

n--;{

if (n > marker.numKeys) n = 0;}

}

}



if (n == 0){

0

}else{

m = marker.key(n);

m1 = marker.key(n+1);

myComment = m.comment;

myComment1 = m1.comment;



c= action.marker.key(myComment).time;

c1=action.marker.key(myComment1).time;

d=marker.key(myComment).time;

d1=marker.key(myComment1).time;



ease(time,d,d1,c,c1);



}

Re: easing remapped time between markers

Posted: November 16th, 2008, 6:05 pm
by Dan Ebberts
It might be that you only need to change this line:

if (n > marker.numKeys) n = 0;}

to this:

if (n > marker.numKeys-1) n = 0;}

Hard to say for sure though, without knowing exactly what you're trying to do.


Dan

Re: easing remapped time between markers

Posted: November 17th, 2008, 12:15 am
by antoska
Layer still looking for markers...

I have got a Composition (5 seconds duration) with a PreComp layer (time remapped) with six markers. The original comp has got 6 markers too but on 14 seconds. It just a correspondence. Marker number 1 time will be number one time on the other comp, etc.

The problem is when time reaches last keyframe says me... "this property has no keyfame number 8" "error ocurred at line..." here:
m1 = marker.key(n+1);

Re: easing remapped time between markers

Posted: November 17th, 2008, 7:58 am
by Dan Ebberts
This one might work better for you:

Code: Select all

L =thisComp.layer("target") ;

max = Math.min(L.marker.numKeys,marker.numKeys);
if (max > 0){
  n = 0;
  if (L.marker.numKeys > 0){
  n = L.marker.nearestKey(time).index;
    if (L.marker.key(n).time > time){
      n--;
    }
  }

  if (n == 0){
    t1 = 0;
    t2 = L.marker.key(1).time;
    t3 = 0;
    t4 = marker.key(1).time;
    linear(time,t1,t2,t3,t4);
  }else if (n >= max){
    marker.key(max).time + (time - L.marker.key(max).time);
  }else{
    t1 = L.marker.key(n).time;
    t2 = L.marker.key(n+1).time;
    t3 = marker.key(n).time;
    t4 = marker.key(n+1).time;
    linear(time,t1,t2,t3,t4);
  }
}else{
  value
}

You'll have to adjust the first line and you might want to change linear() to ease(), but play around with it.

Dan

Re: easing remapped time between markers

Posted: November 19th, 2008, 2:40 pm
by antoska
Thanks Dan,

with some text corrections it is working fine. This is my final expression

Code: Select all

L =thisComp.layer("source") ;
M=comp("source").layer("White Solid 1").marker;

max = Math.min(L.marker.numKeys,M.numKeys);
if (max > 0){
  n = 0;
  if (L.marker.numKeys > 0){
  n = L.marker.nearestKey(time).index;
    if (L.marker.key(n).time > time){
      n--;
    }
  }

  if (n == 0){
    t1 = 0;
    t2 = L.marker.key(1).time;
    t3 = 0;
    t4 = M.key(1).time;
    ease(time,t1,t2,t3,t4);
  }else if (n >= max){
    M.key(max).time + (time - L.marker.key(max).time);
  }else{
m=marker.key(n)
m1=marker.key(n+1)
myComment=m.comment
myComment1=m1.comment

    t1 = L.marker.key(n).time;
    t2 = L.marker.key(n+1).time;
    t3 = M.key(myComment).time;
    t4 = M.key(myComment1).time;


    ease(time,t1,t2,t3,t4);
  }
}else{
  value
}