8 Replies Latest reply on Apr 2, 2010 5:48 PM by Point Happy

    Want to do an irregularly timed loop

    Point Happy

      I'm making an animation that is supposed to represent people phoning into our sales team.  The calls come in irregularly.  I'm making a little glow routine to represent when the call begins.  I could grab keyframes and paste them hundreds of times and end up with a big mess.

       

      But it seems neater to precomp the animation, bring that into a layer and use a keyframe to start the precomp playing at it's beginning each time I needed to.  I looked at time-remapping, but this didn't work.  I wondered if I could write an expression that would do the equivalent of gotoAndPlay in Actionscript.  After reading the standard documentation,  I didn't seem to be much closer to figuring it out.

       

      Any suggestions?

       

      Thanks.

        • 1. Re: Want to do an irregularly timed loop
          TimeRemapper Level 4

          I'm not sure how time remapping wouldn't work for this. Can you please explain what exactly you've tried?

          • 2. Re: Want to do an irregularly timed loop
            Point Happy Level 1

            Well,

             

            I realize that with time remapping, I could make one key frame to start it, and one to stop it and then another to start it again.

             

            But I have hundreds of these, not much time to do it, and the gap between the "phone calls" is sometimes less than the length of the precomp.  So it seemed that if I can just have a single expression at a keyframe that kicks the precomp back to it's in point and then lets it play happily along till it's interrupted again.  That seemed the easiest way to do it.

             

            But now thinking, perhaps, I can take pairs of keyframes and then pop in another keyframe if the time is too short.  The only problem then would be if I have to go back and make adjustments.

            • 3. Re: Want to do an irregularly timed loop
              Mylenium Most Valuable Participant

              Even an expression would still need a trigger event (marker, keyyframe) to determine the start time at least, so I'm not sure what you hope to achieve. Makes no difference if you keyframe the time remap itself or an expression control. Both will yield almost the same number of keyframes. The only other option would be to construct an algorithm that does it all internally in the expression using random timing and the duration of the clip as triggering criteria, but that may not be what you want. So ultimately, I guess you are still stuck with haviung to create a whole lot of keyframes one way or the other.

               

              Mylenium

              • 4. Re: Want to do an irregularly timed loop
                Point Happy Level 1

                Yes, I realize that there will be a lot of keyframes either way, but two keyframes per event is twice as many as 1 keyframe per event.  You can understand why I would like to modularize it, for simplicity, changeability and maintainability.

                 

                So is there a way I can use an expression to control this?  What expression would I use?

                 

                 

                Edit:

                 

                I guess I have to ask whether it's even possible for a keyframe to call an expression.  Flash and Director can both call code from a keyframe so I was assuming that this was common enough that it would be possible in After Effects.  I'm not finding anything in the documentation though.

                • 5. Re: Want to do an irregularly timed loop
                  Mylenium Most Valuable Participant

                  You need to adapt your thinking. Expressions don't control anything, they just modify existing property streams. An expression doesn't call keyframes, it obeys its values and modifies them. Some thoughts on the matter:

                   

                  • keep everything in a loop  - while (time < thisComp.duration){}
                  • add a second inner loop to keep count of the keyframes - for (i=0,i < numKeys,i++)
                  • in the loop, compare current time with the keyframe's time  - if (time <= key(i).time){}
                  • increment the counter every time it passes a key
                  • based on that, remap the time - linear (time,key(i).time,key(i).time+remapDuration,0,clipDuration) (fill in the reqquired values for clipDuration and remapDuration)

                   

                  If you know your way around ActionScript, you should be able to figure out the rest and construct your code.

                   

                  Mylenium

                  • 6. Re: Want to do an irregularly timed loop
                    Point Happy Level 1

                    Now I understand.

                     

                    I was hoping as I said before that perhaps keyframes could call expressions not the other way around.  But I see that this doesn't work either.

                     

                    So, time having run out, I'm going to have to go with the brute force method.  Time remap cycles, beginning, end, beginning for each "phone" event.

                     

                    Thanks for your time.

                    • 7. Re: Want to do an irregularly timed loop
                      Todd_Kopriva Level 8

                      You can place layer markers and have an expression that does something based on the layer markers. Here are some pages with examples:

                       

                      "Expression example: Animate scale at each layer marker"

                       

                      an expression that reads out marker parameters

                       

                      So, you could just place a marker on each layer to indicate the starting point of your animation.

                      • 8. Re: Want to do an irregularly timed loop
                        Point Happy Level 1

                        Thanks.

                         

                        I will take a look at them.  My deadline has passed, so for this time I'm stuck with doing it with many keyframes, but I'll check it out for the future.