ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Re: Use a switch like expression

COW Forums : Adobe After Effects Expressions

FAQ   •   VIEW ALL   •   ADD A NEW POST   •   PRINT
Respond to this post   •   Return to posts index   •   Read entire thread


Levi George
Re: Use a switch like expression
on Dec 6, 2012 at 1:04:11 pm

Hi Dan

Thanks so much for your help. While looking at your script I looked up some of the terms you used and I wasn't aware of how to use a for () condition for looping. I played around with it and I managed to re write my original script to get it working the way I wanted. Thanks so much for all your help, I never would have figured it out without your assistance.

i = 1 ;
j = 1 ;
CurrentTime = timeToFrames(time) ;
MouthPosFind = comp("Lipsync_Code").layer("Frames").effect("Frames")("Slider") ;
FramesSinceKey = 1 ;
FramesSinceStart = timeToFrames(time - comp("PUT_LIPSYNC_CODE_IN_HERE").layer("Lipsync_Code").inPoint) ;
FramesUntillKey = 1 ;
FramesUntillEnd = timeToFrames(comp("PUT_LIPSYNC_CODE_IN_HERE").layer("Lipsync_Code").outPoint)-(timeToFrames(time)) ;

// find frames since last keyframe ;

for (i = 1 ; MouthPosFind.valueAtTime(time)== MouthPosFind.valueAtTime(time-(framesToTime(i))) ; i++)
{
if(MouthPosFind.valueAtTime(time)== MouthPosFind.valueAtTime(time-(framesToTime(i))))
{
FramesSinceKey++ ;
} ;
if(FramesSinceKey>FramesSinceStart)
{
break
} ;
// code stops the value from going backwards forever in the first few frames ;
} ;
// find frames untill next keyframe ;

for (j = 1 ; MouthPosFind.valueAtTime(time)== MouthPosFind.valueAtTime(time+(framesToTime(j))) ; j++)
{if(MouthPosFind.valueAtTime(time)== MouthPosFind.valueAtTime(time+(framesToTime(j))))
{
FramesUntillKey++ ;
}else{break ;} ;

if(FramesUntillKey>=FramesUntillEnd)
{
break
} ;
// code stops the value from going backwards forever in the first few frames ;
} ;

value = FramesSinceKey -1 + FramesUntillKey ;


Posts IndexRead Thread 


Current Message Thread:





© 2019 CreativeCOW.net All Rights Reserved
[TOP]