Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Stoping a looping animation code at certain time

Explorer ,
Nov 25, 2013 Nov 25, 2013

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?

TOPICS
ActionScript
408
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 25, 2013 Nov 25, 2013

You should get any code "on..." objects off of them and keep it all in the timelline.

You can use the setTimeout() function to take care of timing out at 30 seconds and cancelling whatever other code you have processing.  Look it up in the help documentation or search Google for how to use it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 25, 2013 Nov 25, 2013
LATEST

Thanks, I will take a look at this function as suggested.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines