2 Replies Latest reply on Nov 25, 2013 5:04 AM by Kyle Hawkins

    Stoping a looping animation code at certain time

    Kyle Hawkins Level 1

      I am using a code which creates a twinkling star effect. I need to make the effect stop at either 30seconds of itplaying or if possible on a certain frame.

      Here is the code I am using:

       

      onClipEvent (enterFrame) {

      getTargetAlpha = function(){

                return Math.random() * 100;

      };

      this.speed = 9;

      this.target = this.getTargetAlpha();

      this.onEnterFrame = function(){

                if(this._alpha < this.target){

                          this._alpha += this.speed;

                }else if(this._alpha > this.target){

                          this._alpha -= this.speed;

                }else if(this._alpha == this.target){

                          this.target = this.getTargetAlpha;

                }

      };

      }

       

      Is it possible to apply something to achieve this?