# SetInterval animation

**URL:** <https://forum.kirupa.com/t/setinterval-animation/329316>\
**Category:** flash\
**Created:** [August 13, 2012, 8:05am UTC](https://forum.kirupa.com/t/setinterval-animation/329316 "2012-08-13T08:05:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![marvker](https://avatars.discourse-cdn.com/v4/letter/m/9f8e36/32.png) [@marvker](https://forum.kirupa.com/u/marvker)\
**Post date:** [August 13, 2012, 8:05am UTC](https://forum.kirupa.com/t/setinterval-animation/329316/1 "2012-08-13T08:05:19Z")

</div>

Hi guys,

I have a script where the image is animated with setInterval.  
After you pressed the enter button it also leaves animated.  
I’ve been trying a few days to get it so that the picture comes  
and after a few seconds leaves animated without having to press the enter button.  
I know it has to be done with setInterval but I don’t know how.  
Can someone explain to me how I can get it to work.

Thanks in advance.  
Marv

```auto

import gs.*;
import gs.plugins.*;
import gs.easing.*;

glow_mc._visible = false;
glow_mc._alpha = 0;
enter_mc._visible = false;
enter_mc._alpha = 0;

TweenPlugin.activate([ShortRotationPlugin, AutoAlphaPlugin, BlurFilterPlugin]);
stop();

function pictureImplode() {
 enterbtnin = setInterval(showEnterBtn, 2600);
 for (var i=0; i<100; i++) {
  var theClip = this["fj"+(i+1)];
  var theX = 0-(random(Stage.width+100)+(Stage.width/2));
  var theY = random(Stage.height+100)-(Stage.height/2);
  var firstNumber = random(2)+1;
  var secondNumber = random(9)+1;
  var timeString = String(firstNumber + "." + secondNumber);
  var theTime = Number(timeString);
  //var widthheight = 10;
  var widthheight = random(40);
  TweenMax.from(theClip, theTime, {_width:widthheight, _height:widthheight, _x:Math.floor(theX), _y:Math.floor(theY),_rotation:random(970), blurFilter:{blurX:20, blurY:20, quality:1}, ease:Regular.easeOut});
 }
}

function pictureExplode() {
 fadeExplosion = setInterval(fadeAll, 1600);
 for (var i=0; i<100; i++) {
  var theClip = this["fj"+(i+1)];
  var theX = random(Stage.width+100)+(Stage.width/2);
  var theY = random(Stage.height+100)-(Stage.height/2);
  var firstNumber = random(1)+1;
  var secondNumber = random(9);
  var timeString = String(firstNumber + "." + secondNumber);
  var theTime = Number(timeString);
  //var widthheight = 10;
  var widthheight = random(20);
  TweenMax.to(theClip, theTime, {_width:widthheight, _height:widthheight, _x:Math.floor(theX), _y:Math.floor(theY), _rotation:random(970), blurFilter:{blurX:20, blurY:20, quality:3}, ease:Strong.easeIn});
 }
}

function fadeAll() {
 fadeExp();
 enter_mc._visible = false;
}

function fadeExp() {
 clearInterval(fadeExplosion);
 nextframeint = setInterval(nextframe, 1000);
 for (var i=0; i<100; i++) {
  var theClip = this["fj"+(i+1)];
  var firstNumber = 0;
  var secondNumber = random(9)+1;
  var timeString = String(firstNumber + "." + secondNumber);
  var theTime = Number(timeString);
  TweenMax.to(theClip, theTime, {_alpha:0, ease:Linear.easeNone});
 }
}

function nextframe() {
 _parent.play();
}

function showEnterBtn() {
 clearInterval( enterbtnin );
 glow_mc._visible = true;
 enter_mc._visible = true;
 TweenMax.to(enter_mc, 1.5, {_alpha:100, ease:Linear.easeNone});
 TweenMax.to(glow_mc, 0.5, {_alpha:100, ease:Linear.easeNone});
}

function pictureExplosion() {
 glow_mc._visible = false;
 pictureExplode();
}

enter_mc.onRelease = function() {
 TweenMax.to(enter_mc, 1.5, {_alpha:0, ease:easeNone, onComplete:pictureExplosion});
 enter_mc.enabled = false;
 glow_mc.enabled = false;
}

glow_mc.onRelease = function() {
 TweenMax.to(enter_mc, 1.5, {_alpha:0, ease:easeNone, onComplete:pictureExplosion});
 enter_mc.enabled = false;
 glow_mc.enabled = false;
}

var enterbtnin
var fadeExplosion
var nextframeint
pictureImplode();

```
