FORUMS: list search recent posts

Can I use a 'switch' like code to deactivate a varible

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Levi George
Can I use a 'switch' like code to deactivate a varible
on Dec 4, 2012 at 1:11:28 pm

Hi everyone!
Here's my problem:

I have a stepped graph in comp("Lipsync_Code").layer("Frames").effect("Frames")("Slider").

I'm writing a piece of code that I want to do the following:

Find the amount of frames in each 'step' and use that as it's value.

Example time:
Say from frames 1 to 20 the value of my stepped graph is 5. at Frame 21 to 23 the value steps up to 7. If the time slider is located on frames 1 - 20. I want it to be able to figure out and tell me how many frames on this step (There's 20). If it's on frames 21-23 I want it to be able to tell me there's 3 frames.

I'm fairly new to coding but I do consider myself to be half smart and I've been playing around with code for the past month though and here is my idea.

I need two similar pieces of code. Based off the current time, I need to be able to check how many frames SINCE the LAST change in value and how many frames UNTIL the NEXT change in value. Then I need to add them together.

But this idea turned out to be easier said than done. Here is my code to figuring out how long until the next variable change.

MouthPosFind = comp("Lipsync_Code").layer("Frames").effect("Frames")("Slider") ;
// the location of the stepped graph ;
Switch = 1 ;
AddFrame = 1 ;
Switch = 0;
{ AddFrame = AddFrame } ;


{AddFrame=AddFrame + 1} ;

Of course what happens is; the switch variable gets reset to 1 when the switch variable is reset to 1 at the 3rd line of the code and my hard work adding +1 to the AddFrame is for naught because the switch turns itself back on and consequently AddFrame it resets it back to 1. GRR! FOILED BY MY OWN CREATION! (I'm trying to make this a little entertaining so it's not terrible for you reading this long post.)

Maybe if could make another switch to turn that first switch off and continue doing it in an endless loop til either me or After Effects goes insane but that sounds unpleasant.

Am I in the right ballpark here? I know what I logically how to set this up, I just lack the coding know how to pull it off.

Any advice would be hugely appreciated. I've been stuck on this for 2 days now.

Thanks heaps!

Return to posts index

Joseph W. Bourke
Re: Can I use a 'switch' like code to deactivate a varible
on Dec 4, 2012 at 3:19:14 pm

I think you'll get a quicker answer in the Expressions forum.

Joe Bourke
Owner/Creative Director
Bourke Media

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved