Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Initializing values in an expression/ Counter Incrementing

  • Initializing values in an expression/ Counter Incrementing

    Posted by Forrest Maready on August 21, 2008 at 9:54 pm

    Hey Everybody!
    I’m trying to run a counter in an expression. I need to initialize the variable so that if the counter hasn’t incremented it on a previous frame the variable is created with value 0. If the counter has already been incremented, I just want to leave the value as is.

    Does this code look right to you guys?

    if (peakCounter = null)
    {
    peakCounter = 0;
    }

    Thanks!

    Anas Maghraoui replied 10 years, 9 months ago 3 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    August 22, 2008 at 12:50 am

    I think you’re assuming that expression values can persist from frame to frame, which is not the case. I’m afraid there’s no way for an expression to communicate with itself from one frame to the next. There is probably a work-around though, depending on what you’re trying to do.

    Dan

  • Forrest Maready

    August 22, 2008 at 1:54 am

    Yeah I was afraid of that. I’ve been racking my head, trying to come up with a workaround but so far to no avail. I usually code in Flash/AS3 so I was assuming too much (or too little).

    If anyone comes up with a workaround, I’d love to hear it. I’m trying to run a counter based off the current (time) property but the counter needs to be resettable- that’s the rub.

    Thanks

  • Dan Ebberts

    August 22, 2008 at 1:57 am

    What initiates the reset?

    Dan

  • Anas Maghraoui

    July 31, 2015 at 2:56 pm

    i have the same probleme and my solution is to use a slide property on the layer as a global variable

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy