Using the Sine Wave formula from the previous post, I created this random fizz.
import flash.filters.BlurFilter; // init vars var SW = Stage.width; var SH = Stage.height; var clips = 35; var minScale = 10; var maxScale = 100; /* ------------------------------------------------------------------------ INIT ANIMATION ---------------------------------------------------------------------- */ initAnim = function() { // Move Clip this.bubble._x = this.centerX + Math.sin(this.angle) * this.range; this.angle += this.vx; this._y -= this.vy; // Reset Position if (this._y < 0) { this._y = SH+this._height; this._x = Math.floor(Math.random() * SW); } } /* ------------------------------------------------------------------------ INIT STAGE ---------------------------------------------------------------------- */ initStage = function () { for (i = 0; i <= clips; ++i) { // Create Clips var clip = this.createEmptyMovieClip("clip", i); var bubble = clip.attachMovie("bubble", 'bubble', i); // Set init size and position clip._xscale = clip._yscale = minScale + Math.floor(Math.random() * maxScale); clip._x = Math.floor(Math.random() * SW); clip._y = SH + 100; clip.bubble._x = -(clip.bubble._width/2); // set movement vars clip.angle = 0; clip.range = 15 + Math.floor(Math.random() * 35); clip.vx = .05 + Math.random() * .25; clip.vy = 5 + Math.random() * 15; clip.centerX = clip.bubble._x; // Create Variable to determine depth for blur/Alpha amount z = 10 + Math.random() * 50; // Add Blur var blur = new BlurFilter(); clip.tempFilter = clip.filters; clip.tempFilter.push(blur); // blur (max quality is 15) clip.tempFilter[0].quality = z * .02; clip.filters = clip.tempFilter; // render movement clip.onEnterFrame = initAnim; } } initStage(); stop();
Leave a Reply