Section 1
//Circle (ae.Circle)
package ae {
import flash.events.*;
import flash.display.*;
import ae.*;
class Circle extends Sprite {
public var r2:Number;
public var node:CircleNode;
public var c:int;
public var h:Number;
private var t:Number;// = 0
public var w:Number;
public var r:Number;
private var step:Number;// = 0.06
function Circle(_w:Number, _h:Number){
var red:int;
var g:int;
var b:int;
t = 0;
step = 0.06;
super();
w = _w;
h = _h;
r = (w / 2);
r2 = (r / 2);
red = (int((Math.random() * 224)) + 32);
g = (int((Math.random() * 224)) + 32);
b = (int((Math.random() * 224)) + 32);
c = (((red << 16) + (g << 8)) + b);
}
public function split():void{
var c1:Circle;
var c2:Circle;
var c3:Circle;
var c4:Circle;
var ymid:Number;
var xmid:Number;
var cn1:CircleNode;
var cn2:CircleNode;
var cn3:CircleNode;
var cn4:CircleNode;
c1 = new Circle(r, r);
c2 = new Circle(r, r);
c3 = new Circle(r, r);
c4 = new Circle(r, r);
ymid = (y + r);
xmid = (x + r);
c1.x = x;
c1.y = y;
c2.x = xmid;
c2.y = y;
c3.x = x;
c3.y = ymid;
c4.x = xmid;
c4.y = ymid;
cn1 = new CircleNode(c1);
cn2 = new CircleNode(c2);
cn3 = new CircleNode(c3);
cn4 = new CircleNode(c4);
cn1.xThresh = (xmid - r2);
cn1.yThresh = (ymid - r2);
cn2.xThresh = (xmid + r2);
cn2.yThresh = (ymid - r2);
cn3.xThresh = (xmid - r2);
cn3.yThresh = (ymid + r2);
cn4.xThresh = (xmid + r2);
cn4.yThresh = (ymid + r2);
node.addChildren(cn1, cn2, cn3, cn4);
(this.parent as CircleSplit).addCircles(new Array(c1, c2, c3, c4));
node.parentCircle = null;
node = null;
this.parent.removeChild(this);
}
private function handleFrame(e:Event){
if (t >= 1){
removeEventListener(Event.ENTER_FRAME, handleFrame);
split();
} else {
t = (t + step);
draw();
};
}
public function draw():void{
this.graphics.clear();
if (t == step){
(this.parent as CircleSplit).blankBG(this);
};
this.graphics.beginFill(c);
this.graphics.drawCircle(lerp(r, (r - r2), t), lerp(r, (r - r2), t), lerp(r, r2, t));
this.graphics.endFill();
this.graphics.beginFill(c);
this.graphics.drawCircle(lerp(r, (r - r2), t), lerp(r, (r + r2), t), lerp(r, r2, t));
this.graphics.endFill();
this.graphics.beginFill(c);
this.graphics.drawCircle(lerp(r, (r + r2), t), lerp(r, (r - r2), t), lerp(r, r2, t));
this.graphics.endFill();
this.graphics.beginFill(c);
this.graphics.drawCircle(lerp(r, (r + r2), t), lerp(r, (r + r2), t), lerp(r, r2, t));
this.graphics.endFill();
}
private function lerp(a:Number, b:Number, t:Number):Number{
return (((a * (1 - t)) + (b * t)));
}
private function hitTest(e:MouseEvent):Boolean{
var dx:Number;
var dy:Number;
var dist:*;
dx = Math.abs(((x + r) - e.stageX));
dy = Math.abs(((y + r) - e.stageY));
dist = Math.sqrt(((dx * dx) + (dy * dy)));
return ((dist <= r));
}
public function handleMouseOver(e:MouseEvent){
if (e.buttonDown){
return;
};
if (t > 0){
return;
};
if (!hitTest(e)){
return;
};
addEventListener(Event.ENTER_FRAME, handleFrame);
this.graphics.clear();
}
}
}//package ae
Section 2
//CircleNode (ae.CircleNode)
package ae {
import flash.events.*;
class CircleNode {
public var xThresh:Number;
protected var parent:CircleNode;// = null
protected var child1:CircleNode;// = null
protected var child2:CircleNode;// = null
protected var child3:CircleNode;// = null
protected var child4:CircleNode;// = null
public var parentCircle:Circle;// = null
public var yThresh:Number;
function CircleNode(pc:Circle){
parentCircle = null;
parent = null;
child1 = null;
child2 = null;
child3 = null;
child4 = null;
super();
parentCircle = pc;
pc.node = this;
}
public function addChildren(c1:CircleNode, c2:CircleNode, c3:CircleNode, c4:CircleNode):void{
child1 = c1;
child2 = c2;
child3 = c3;
child4 = c4;
c1.parent = this;
c2.parent = this;
c3.parent = this;
c4.parent = this;
}
public function findTarget(e:MouseEvent):void{
if ((((((((child1 == null)) && ((child2 == null)))) && ((child3 == null)))) && ((child4 == null)))){
if (parentCircle != null){
parentCircle.handleMouseOver(e);
};
return;
};
if ((((((e.stageX < xThresh)) && ((e.stageY < yThresh)))) && (!((child1 == null))))){
child1.findTarget(e);
} else {
if ((((((e.stageX > xThresh)) && ((e.stageY < yThresh)))) && (!((child2 == null))))){
child2.findTarget(e);
} else {
if ((((((e.stageX < xThresh)) && ((e.stageY > yThresh)))) && (!((child3 == null))))){
child3.findTarget(e);
} else {
if ((((((e.stageX > xThresh)) && ((e.stageY > yThresh)))) && (!((child4 == null))))){
child4.findTarget(e);
};
};
};
};
}
public function deleteMe():void{
parentCircle = null;
child1 = null;
child2 = null;
child3 = null;
child4 = null;
if (parent != null){
parent.killChild(this);
parent = null;
};
}
public function isEmpty():Boolean{
return ((((((((child1 == null)) && ((child2 == null)))) && ((child3 == null)))) && ((child4 == null))));
}
public function killChild(c:CircleNode):void{
if (c == child1){
child1 = null;
};
if (c == child2){
child2 = null;
};
if (c == child3){
child3 = null;
};
if (c == child4){
child4 = null;
};
if (isEmpty()){
deleteMe();
};
}
}
}//package ae
Section 3
//CircleSplit (ae.CircleSplit)
package ae {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.geom.*;
public class CircleSplit extends MovieClip {
public var rootNode:CircleNode;
private var win:Boolean;// = false
public var sp:Boolean;// = false
protected var bgHolder:Sprite;
public static var bg:Bitmap;
private static var bgb:BitmapData;
public function CircleSplit(){
win = false;
sp = false;
super();
bgb = new BitmapData(0x0400, 0x0400, false, 0);
bg = new Bitmap(bgb);
bg.smoothing = true;
bgHolder = new Sprite();
addChild(bgHolder);
bgHolder.addChild(bg);
createCircle(0x0400, 0, 0);
}
public function createCircle(size:Number, x:Number, y:Number){
var w:*;
var circle:Circle;
w = 0x0400;
circle = new Circle(w, w);
circle.x = ((0x0400 - w) / 2);
circle.y = ((0x0400 - w) / 2);
this.addChild(circle);
drawCircle(circle);
rootNode = new CircleNode(circle);
rootNode.xThresh = 0x0200;
rootNode.yThresh = 0x0200;
addEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove);
}
public function drawCircle(c:Circle){
var s:Sprite;
var m:Matrix;
s = new Sprite();
s.graphics.beginFill(c.c);
s.graphics.drawCircle(c.r, c.r, c.r);
s.graphics.endFill();
m = new Matrix();
m.tx = c.x;
m.ty = c.y;
bg.bitmapData.draw(s, m);
}
public function blankBG(c:Circle){
var s:Sprite;
var m:Matrix;
s = new Sprite();
s.graphics.beginFill(0);
s.graphics.drawRect(0, 0, c.w, c.w);
s.graphics.endFill();
m = new Matrix();
m.tx = c.x;
m.ty = c.y;
bg.bitmapData.draw(s, m);
}
public function addCircles(a:Array){
var obj:Object;
var c:Circle;
sp = true;
if (a[0].w > 4){
for each (obj in a) {
addChild((obj as Circle));
};
} else {
for each (obj in a) {
c = (obj as Circle);
c.node.deleteMe();
};
};
for each (obj in a) {
drawCircle((obj as Circle));
};
}
public function handleMouseMove(e:MouseEvent){
rootNode.findTarget(e);
if (((((rootNode.isEmpty()) && (!(win)))) && (sp))){
win = true;
navigateToURL(new URLRequest("http://www.youtube.com/watch?v=M5QGkOGZubQ#t=0m4s"), "_blank");
};
}
}
}//package ae