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

📄 particle3d_class.as

📁 这是《Flash MX编程与创意实现》的源代码
💻 AS
字号:
/*
  Particle3d Class 
  Oct. 29, 2002
  (c) 2002 Robert Penner
  
  This custom object represents and renders a visual particle
  existing in a simulated three-dimensional space.
  The appearance of the particle is represented by an
  attachable movie clip, and its position by a Vector3d instance.
  
  Dependencies: 
  - Vector3d class
  - trig_functions_degrees.as
  
  Discussed in Chapter 5 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 Math.cosD != "function") trace ("error: Math.cosD function mission");

// add check for Vector3d class

_global.Particle3d = function (x, y, z, timeline, mcID, depth) {
	this.position = new Vector3d (x, y, z);
	this.timeline = timeline;
	this.mc = this.attachGraphic (mcID, depth);
	this.scale = 100;
	this.render();
}

Particle3d.prototype.attachGraphic = function (mcID, depth) {
	return this.timeline.attachMovie (mcID,
									  mcID + "_" + depth,
									  depth);
};


Particle3d.prototype.render = function () {
	var pers = this.position.getPerspective();
	this.screenPos = this.position.persProjectNew (pers);
	with (this.mc) {
		_x = this.screenPos.x;
		_y = -this.screenPos.y;
		_xscale = _yscale = this.scale * pers;
		swapDepths (100000 - this.position.z * 100);
	}
};

trace (">> Particle3d class loaded");

⌨️ 快捷键说明

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