package { import mx.controls.Image; public class student_twitter_flock_Tree { private var x:int, y:int; private var radius:int = 75; public var image:Image; public function student_twitter_flock_Tree (x:int, y:int, image:Image):void { this.x = x; this.y = y; this.image = image; this.image.x = x - 75; this.image.y = y - 75; } public function getX ():int { return this.x; } public function getY ():int { return this.y; } public function getRadius ():int { return this.radius; } public function getImage ():Image { return this.image; } public function distanceToBoid (boid:student_twitter_flock_Boid):int { var distX:int = this.x - boid.getX(), distY:int = this.y - boid.getY(); return Math.sqrt(distX * distX + distY * distY); } public function shake (boids:Array):void { // Find all boids within the tree radius and give them a random impulse. // The result is that they scatter. for(var i:int = 0; i < boids.length; i++) { if (this.distanceToBoid(boids[i]) <= this.radius) { boids[i].addRandomImpulse (10.0); } } } } }