Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thanks, I will take a look at this function as suggested.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now