var foam, vx, vy, vr:Array;
var i:int;
const spectrum=21;
foam = new Array(spectrum);
vx = new Array(spectrum);
vy = new Array(spectrum);
vr = new Array(spectrum);
var foamCounter: int;
foamCounter = 0;
for (i=0; i<spectrum; i=i+7) {
foam[i+0] = new red();
foam[i+1] = new orange();
foam[i+2] = new yellow();
foam[i+3] = new green();
foam[i+4] = new blue();
foam[i+5] = new violet();
foam[i+6] = new red();
}
for (i=0; i<spectrum; ++i) {
addChild(foam[i]);
foam[i].x=10000;
foam[i].y=10000;
}
stage.addEventListener(MouseEvent.CLICK, makeFoam);
stage.addEventListener(MouseEvent.MOUSE_MOVE, makeFoam);
function makeFoam(e:MouseEvent) {
foam[foamCounter].x = e.stageX;
foam[foamCounter].y = e.stageY;
foam[foamCounter].alpha = 1.0;
foam[foamCounter].rotation = 0.0;
++foamCounter;
if (foamCounter>=spectrum) {
foamCounter=0;
}
vx[foamCounter] = 10.0*(Math.random()-0.5);
vy[foamCounter] = 10.0*(Math.random()-0.5);
vr[foamCounter] = 10.0*(Math.random()-0.5);
vr[foamCounter]*=vr[foamCounter];
} |