# Scripting a Snowflake Mask

**URL:** <https://forum.kirupa.com/t/scripting-a-snowflake-mask/244658>\
**Category:** flash\
**Created:** [November 20, 2007, 5:11pm UTC](https://forum.kirupa.com/t/scripting-a-snowflake-mask/244658 "2007-11-20T17:11:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wyclef](https://avatars.discourse-cdn.com/v4/letter/w/65b543/32.png) [@wyclef](https://forum.kirupa.com/u/wyclef)\
**Post date:** [November 20, 2007, 5:11pm UTC](https://forum.kirupa.com/t/scripting-a-snowflake-mask/244658/1 "2007-11-20T17:11:23Z")

</div>

How could I modify this code to keep the flakes from falling within 12px on all four sides plus a 22 radius on the corners. I could just load the swf into a master file to accomplish this but it’s gonna be such a simple piece I was hoping there could be a way to just use code to do it. Also, this AS only works as 1.0 and Flash Player 6. Any clue how to upgrade it?

```auto

// snowflakes
amount = 100;
mWidth = Stage.width;
mHeight = Stage.height;
for (var i = 0; i<amount; i++) {
	thisFlake = this.attachMovie("flake", "flake"+i, i);
	with (thisFlake) {
		_x = Math.random()*mWidth;
		_y = Math.random()*mHeight;
		_xscale = _yscale=_alpha=40+Math.random()*60;
	}
	thisFlake.yspeed = Math.random()*2+.2;
	thisFlake.increment = -0.025+Math.random()*0.05;
	thisFlake.radian = 0; //declare for actionscript 2.0
	thisFlake.onEnterFrame = function() {
		this.radians += this.increment;
		//trace(this.radians);
		this._x += Math.sin(this.radians);
		this._y += this.yspeed;
		if (this._y>=mHeight) {
			this._y = -10;
			this._x = -10+Math.random()*mWidth;
		}
		if (this._x>=mWidth || this._x<=0) {
			this._y = -10;
			this._x = -10+Math.random()*mWidth;
		}
	};
}

```
