So I’m still relatively new to Flash scripting. I’ve got a hold of Brain Giants falling snow module and which looks like this.
//Import filter objects to be used in this movie
import flash.filters.BlurFilter;
import flash.geom.Rectangle;
import flash.geom.Point;
//Set the width and height snow bounds (determined from 0)
snowBoundsWidth = 800;
snowBoundsHeight = 600;
blur_mc.blurOn = 0;
//Total number of flakes to be created
flakes = 50;
for (i=0; i<flakes; i++) {
//Create an empty movie clip and attach the snowflake
this.createEmptyMovieClip("snow"+i, this.getNextHighestDepth());
this["snow"+i].attachMovie("snow", "flake", getNextHighestDepth());
//Call function to generate flake properties for each flake
getFlakeProps(this["snow"+i]);
}
function getFlakeProps(flakeID) {
flakeID.cacheAsBitmap = true;
//Randomly scale the flake
flakeID.flakeScale = Math.random()*500;
//Compute the flakeDepth ratio (larger flakes will have a stronger blur and lower alpha)
flakeID.flakeDepth = flakeID.flakeScale/100;
//Randomly rotate the flake
flakeID.flakeRotate = Math.random()*45;
//Set the alpha based on the flakeDepth
flakeID.flakeAlpha = 1/flakeID.flakeDepth*30;
if (flakeID.flakeAlpha>30) {
flakeID.flakeAlpha = 30;
}
//Blur the flake based on the flakeDepth (stronger blur for larger flakes)
flakeID.randomBlur = flakeID.flakeDepth*10;
//Add the blur filter (not at beginning for performance)
//flakeID.flakeBlur = new BlurFilter(flakeID.randomBlur, flakeID.randomBlur, 1);
//flakeID.filters = [flakeID.flakeBlur];
//Scale the flake
flakeID._xscale = flakeID._yscale=flakeID.flakeScale;
//Set the flake alpha
flakeID._alpha = flakeID.flakeAlpha;
//Set the flake rotation
flakeID._rotation = flakeID.flakeRotate;
//Set a random _x and _y start position
flakeID._x = Math.random()*snowBoundsWidth;
flakeID._y = Math.random()*snowBoundsHeight;
//Compute a random fall speed
flakeID.fallSpeed = 2+Math.random()*10;
//Compute a random fall path and radius
flakeID.fallPath = -Math.PI+Math.random()*Math.PI;
flakeID.radius = Math.random()*10;
//Call function to animate the flake
animateFlake(flakeID);
}
function animateFlake(flakeID) {
//Animate the flake
flakeID.onEnterFrame = function() {
var my_color:Color = new Color(this);
my_color.setRGB(0xffffff);
//Flake horizontal movement
windEffect = flakeID.flakeDepth*3;
flakeID.radius += (flakeID.fallPath/180)*Math.PI;
this._x -= windEffect*(Math.cos(flakeID.radius));
//Flake vertical movement
this._y += flakeID.fallSpeed;
//Change flake color to yellow when in front of light (and increase alpha by 50)
//Set alphaIncrease to be used when flake is in front of light
alphaIncrease = 50;
//Check if flake is currently in a rectangle area surrounding light
var lightArea:Rectangle = new Rectangle(300, 0, 200, 130);
if (lightArea.containsPoint(new Point(this._x, this._y))) {
//Change flake color to yellow
my_color.setRGB(0xffff9e);
//Incresae flake alpha (to appear brighter)
if (this._alpha<(flakeID.flakeAlpha+alphaIncrease)) {
this._alpha += 5;
} else {
this._alpha = flakeID.flakeAlpha+alphaIncrease;
}
} else {
//Change flake color back to white
my_color.setRGB(0x000000);
//Decrease flake alpha (to appear dimmer)
if (this._alpha>flakeID.flakeAlpha) {
this._alpha -= 5;
} else {
this._alpha = flakeID.flakeAlpha;
}
}
//Fade-out flake proportionately toward bottom of screen (simulate melting near ground)
//Set the y position of the metliting line
meltLine = 300;
if (this._y>=meltLine) {
this._alpha = ((snowBoundsHeight-this._y)/((snowBoundsHeight-meltLine)+this._height))*flakeID.flakeAlpha;
}
//Once flake reaches the bottom of the snowBoundsHeight, bring flake back to top
if (this._y>=(snowBoundsHeight+this._height)) {
this._y = 0-this._height;
}
};
}
stop();
And there is an option to blur the flakes based on an on press event
onClipEvent (load) {
blurOn = 1;
import flash.filters.BlurFilter;
}
on (press) {
if (blurOn == 0) {
blurOnOff.text = "on";
blurOn = 1;
for (i=0; i<_parent.flakes; i++) {
_parent["snow"+i].flakeBlur = new BlurFilter(_parent["snow"+i].randomBlur, _parent["snow"+i].randomBlur, 1);
_parent["snow"+i].filters = [_parent["snow"+i].flakeBlur];
}
} else {
blurOnOff.text = "off";
blurOn = 0;
for (i=0; i<_parent.flakes; i++) {
_parent["snow"+i].filters = [];
}
}
}
My Question is how to get the flakes to blur initially when the whole thing loads instead of having to click to toggle it on and off?