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

📄 spring.as

📁 用于flash/flex的 as3的 2D图形图像图表的动态生成
💻 AS
字号:
package flare.physics
{
	/**
	 * Represents a Spring in a physics simulation. A spring connects two
	 * particles and is defined by the springs rest length, spring tension,
	 * and damping (friction) co-efficient.
	 */
	public class Spring
	{
		/** The first particle attached to the spring. */
		public var p1:Particle;
		/** The second particle attached to the spring. */
		public var p2:Particle;
		/** The rest length of the spring. */
		public var restLength:Number;
		/** The tension of the spring. */
		public var tension:Number;
		/** The damping (friction) co-efficient of the spring. */
		public var damping:Number;
		/** Flag indicating that the spring is scheduled for removal. */
		public var die:Boolean;
		/** Tag property for storing an arbitrary value. */
		public var tag:uint;
		
		/**
		 * Creates a new Spring with given parameters.
		 * @param p1 the first particle attached to the spring
		 * @param p2 the second particle attached to the spring
		 * @param restLength the rest length of the spring
		 * @param tension the tension of the spring
		 * @param damping the damping (friction) co-efficient of the spring
		 */
		public function Spring(p1:Particle, p2:Particle, restLength:Number=10,
							   tension:Number=0.1, damping:Number=0.1)
		{
			init(p1, p2, restLength, tension, damping);
		}
		
		/**
		 * Initializes an existing spring instance.
		 * @param p1 the first particle attached to the spring
		 * @param p2 the second particle attached to the spring
		 * @param restLength the rest length of the spring
		 * @param tension the tension of the spring
		 * @param damping the damping (friction) co-efficient of the spring
		 */
		public function init(p1:Particle, p2:Particle, restLength:Number=10,
							 tension:Number=0.1, damping:Number=0.1):void
		{
			this.p1 = p1;
			this.p2 = p2;
			this.restLength = restLength;
			this.tension = tension;
			this.damping = damping;
			this.die = false;
			this.tag = 0;
		}
		
		/**
		 * "Kills" this spring, scheduling it for removal in the next
		 * simulation cycle.
		 */
		public function kill():void {
			this.die = true;
		}
		
	} // end of class Spring
}

⌨️ 快捷键说明

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