# Making a flag animation run more than 3 min with actionscript 2

**URL:** <https://forum.kirupa.com/t/making-a-flag-animation-run-more-than-3-min-with-actionscript-2/327526>\
**Category:** Uncategorized\
**Created:** [March 7, 2012, 9:29am UTC](https://forum.kirupa.com/t/making-a-flag-animation-run-more-than-3-min-with-actionscript-2/327526 "2012-03-07T09:29:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ricspider](https://avatars.discourse-cdn.com/v4/letter/r/a9adbd/32.png) [@Ricspider](https://forum.kirupa.com/u/Ricspider)\
**Post date:** [March 7, 2012, 9:29am UTC](https://forum.kirupa.com/t/making-a-flag-animation-run-more-than-3-min-with-actionscript-2/327526/1 "2012-03-07T09:29:26Z")

</div>

This code is animating a flag but it stops after around 3 min, how can I get this to run forever?

…Code…\>\>

Stage.scaleMode = ‘noScale’;

displace\_mc.createEmptyMovieClip(“perlin”, 1);

var ramp:MovieClip = displace\_mc.ramp;  
ramp.swapDepths(2); // place ramp above perlin noise

// GENERAL variables  
var speed = 8; // speed at which noise is shifted (causes flap)  
var channel = 1; // red - red used to displace pixels along

// DISPLACEMENT variables  
var flapX = 50; // power of pixel displacement along x axis  
var flapY = 100; // power of pixel displacement along y axis  
var mode = “clamp”; // clamp the image so none of the original is seen

var offset = new flash.geom.Point(0, 0); // displacment map offset

var displaceBitmap:flash.display.BitmapData = new flash.display.BitmapData(ramp.\_width, ramp.\_height);  
var displaceFilter:flash.filters.DisplacementMapFilter = new flash.filters.DisplacementMapFilter(displaceBitmap, offset, channel, channel, flapX, flapY, mode);

// PERLINNOISE variables  
var baseX = 80; // size of noise in x axis  
var baseY = 0; // size of noise in y axis  
var octs = 1; // noise functions for noise (smaller = faster)  
var seed = Math.floor(Math.random() \* 50); // random seed for noise  
var stitch = true; // stitching makes the noise wrap making it easy to repeat  
var fractal = true; // use fractal noise  
var gray = false; // grayscale is not used because the red channel is

var noiseBitmap:flash.display.BitmapData = new flash.display.BitmapData(500, 1);  
noiseBitmap.perlinNoise(baseX, baseY, octs, seed, stitch, fractal, channel, gray);

var shift:flash.geom.Matrix = new flash.geom.Matrix();

onEnterFrame = function(){

```
shift.translate(speed, 0);

with (displace_mc.perlin){
    clear();
    beginBitmapFill(noiseBitmap, shift);
    moveTo(0,0);
    lineTo(ramp._width, 0);
    lineTo(ramp._width, ramp._height);
    lineTo(0, ramp._height);
    lineTo(0, 0);
    endFill();
}

displaceBitmap.draw(displace_mc);

flag_mc.filters = [displaceFilter];

```

}
