package {
import flash.display.*;
import flash.events.*;
import flash.geom.Point;
import flash.text.*;
public class Board extends MovieClip {
private var NUM_CIRCLES:int = 100;
private var NONE:int = 0;
private var PARTIAL:int = 1;
private var FULL:int = 2;
private var gameLegend:Legend;
private var circles:Array;
private var circleClickedId:int = -1;
private var mouseDownPos:Point;
private var createdCircleId:int = -1;
private var circleCount:int = 0;
private var conclusions:Array;
public function Board():void {
circles = new Array(NUM_CIRCLES);
conclusions = new Array(NUM_CIRCLES);
for (var i:int = 0; i < gamelegend =" new" x =" 377;" int =" 0;" circleclickedid =" i;">= NUM_CIRCLES) {
return;
}
// Since a shape was not clicked, we will be creating a new
// shape at this position
mouseDownPos = new Point(evt.stageX, evt.stageY);
var venn:VennCircle = new VennCircle(mouseDownPos);
// Get the spot in the array for the circle
for (var j:int = 0; j < createdcircleid =" j;" legenditem =" new" circleclickedid =" -1;" createdcircleid =" -1;" mousedownpos =" null;">= 0) {
// Move the object, but make sure it is still on the board
circles[circleClickedId].updatePosition(evt.stageX, evt.stageY);
// Update the conclusions to display the logic
// behind the venn diagrams
checkConclusions();
} else if (createdCircleId >= 0) {
// Need to update the size of the circle
var xDiff:Number = Math.abs(mouseDownPos.x - evt.stageX);
var yDiff:Number = Math.abs(mouseDownPos.y - evt.stageY);
if (xDiff > yDiff) {
circles[createdCircleId].setRadius(xDiff);
} else {
circles[createdCircleId].setRadius(yDiff);
}
checkConclusions();
}
}
private function deleteItem(evt:Event):void {
//trace("Board: Deleting Item: " + gameLegend.itemTBD);
circleCount--;
this.removeChild(circles[gameLegend.itemTBD]);
circles[gameLegend.itemTBD] = null;
}
private function checkConclusions():void {
// Loop through all of the circle and determine if they
// overlap with any of the other circles
for (var i:int = 0; i < int =" 0;" text = "" int =" 0;" int =" 0;" string = ""> 0) {
if (conclusions[i][j] == PARTIAL) {
tempTxt = "SOME " + gameLegend.itemText(i)
+ " ARE " + gameLegend.itemText(j) + "\n";
txtConclusions.appendText(tempTxt);
} else {
tempTxt = "ALL " + gameLegend.itemText(i)
+ " ARE " + gameLegend.itemText(j) + "\n";
txtConclusions.appendText(tempTxt);
}
} else {
tempTxt = gameLegend.itemText(i)
+ " ARE NOT " + gameLegend.itemText(j) + "\n";
txtConclusions.appendText(tempTxt);
}
}
}
}
}
private function calculateOverlap(cir1:VennCircle, cir2:VennCircle):int {
var pt1:Point = cir1.getPosition();
var pt2:Point = cir2.getPosition();
var rad1:int = cir1.getRadius();
var rad2:int = cir2.getRadius();
var retVal:int = NONE;
if ((Math.pow(pt1.x - pt2.x, 2) +
Math.pow(pt1.y - pt2.y, 2)) < (Math.pow(rad1 + rad2, 2))) { retVal = PARTIAL; // The two circles overlap, now we need to check and // see if one is completely inside of the other one if ((Math.pow(pt1.x - pt2.x, 2) + Math.pow(pt1.y - pt2.y, 2)) < (Math.pow(rad1 - rad2, 2))) { retVal = FULL; if (rad1 < retval =" FULL;" retval =" PARTIAL;" retval =" NONE;">
And then we created this blog! It was really fun, and I'm looking forward to day #2!
Best,
Carson Kahn
www.CarsonKahn.co.nr

Carson,
ReplyDeleteThis was a very vivid explanation of your day and it sure is right up your alley. You are so fortunate to have the opportunity to be engaged in such an indepth, practical and innovative program. Finally, after all your requests for such a program it has appeared!
Enjoy!
SOK