⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 snowstorm_class.as

📁 这是《Flash MX编程与创意实现》的源代码
💻 AS
字号:
/*
  Snowstorm Class v1.1
  Oct. 29, 2002
  (c) 2002 Robert Penner
  
  The Snowstorm class manages a collection of SnowFlake objects,
  defining their limits, friction, falling speed, and wind.
  
  Dependencies: Snowflake class 
  
  Discussed in Chapter 12 of 
  Robert Penner's Programming Macromedia Flash MX
  
  http://www.robertpenner.com/profmx
  http://www.amazon.com/exec/obidos/ASIN/0072223561/robertpennerc-20
*/

if (typeof Snowflake != "function") trace ("Error: required class Snowflake missing");


_global.Snowstorm = function (limits, friction, fallSpeed, timeline) {
	this.limits = limits;
	this.friction = friction;
	this.fallSpeed = fallSpeed;
	this.timeline = timeline;
	this.flakes = []; 
};

var SSP = Snowstorm.prototype;


///////////// PUBLIC METHODS

SSP.addFlake = function () {
	var lm = this.limits;
	var newFlake = new Snowflake (this.fallSpeed,
								  this.timeline,
								  this.flakes.length);
	newFlake.setStorm (this);
	var x = Math.randRangeF (lm.xmin, lm.xmax);
	var y = lm.ymin;
	var z = Math.randRangeF (lm.zmin, lm.zmax);
	newFlake.setZ (z);
	newFlake.setScreenXY (x, y);
	this.flakes.unshift (newFlake);
};

SSP.removeFlake = function () {
	return this.flakes.pop();
};


/////////// GETTER/SETTER METHODS

SSP.setWind = function (w) {
    this.$wind = w;
};

SSP.getWind = function () {
    return this.$wind;
};

/////////// GETTER/SETTER PROPERTIES

with (SSP) {
    addProperty ("wind", getWind, setWind);
}

delete SSP;

trace (">> Snowstorm class loaded");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -