Thursday, June 3, 2010

Phythagorean Theorem - Distance Formula

Sum of the Squares of the two legs of a right triangle is equal to the square of the hypotenuse.

A^2 + B^2 = C^2


var dist:Number;
var circle:Circle;

function onStageEnter(event) {
var dx:Number = event.target.x - mouseX;
var dy:Number = event.target.y - mouseY;
dist = Math.sqrt(dx*dx + dy*dy);
event.target.alpha = 1-(dist/250);
distText.text = String(dist);
distText.x = mouseX;
distText.y = mouseY+20;
}

for (var i:int = 1; i<=7; i++) {

 for (var j:int = 1; j<=5; j++) {

  circle = new Circle();
  circle.x = (i*circle.width)-circle.width;
  circle.y = (j*circle.height)-circle.height;
  circle.addEventListener(Event.ENTER_FRAME, onStageEnter);
  addChild(circle);
 }
}



1 comment:

Unknown said...

I see !!, Your writting could change the world that you want. Express your thoughts!!. Politics , Business , Entertainment , Sports & Games , Life & Events ,and Health what else?. Meet your like minded here. The top social gathering in one place all the top notches meet here. It is not about win the race, participation is all matters. We proud inviting you to the the internet's best Social community. www.jeejix.com .

Post a Comment

Thirukkural