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];
}