Nothing too special here…just having a bit of fun with an idea that occurred to me about 30 minutes ago.
Anyhow, as the title suggests, this SWF draws dynamic bubbles on the screen. Just click, drag, and release to set the size and voila! An instant bubble. Repeat ad infinitum.
Your bubbles (with random fill and line colours) will float upwards (with random speeds) until they touch the top of the window; whereupon each bubble will merrily burst having filled your life with at least one happy bubblicious moment for the entirety of its 699 byte existence.
All of the actionmagicscript is here:
var counter:Number = 0;
onMouseDown = function () {
var startX:Number = _xmouse;
var startY:Number = _ymouse;
onMouseUp = function () {
var distX:Number = Math.round(_xmouse - startX);
var distY:Number = Math.round(_ymouse - startY);
radius = Math.round(Math.sqrt((distX * distX) + (distY * distY)));
circle_mc = this.createEmptyMovieClip("circle_mc" + counter, getNextHighestDepth());
circle_mc.lineStyle(0, Math.random() * 0xFFFFFF);
circle_mc.beginFill(Math.random() * 0xFFFFFF);
drawCircle(circle_mc, startX, startY, radius);
circle_mc.endFill();
};
};
function drawCircle(mc:MovieClip, x:Number, y:Number, r:Number):Void {
mc.y = y;
mc.r = r;
mc.moveTo(x + r, y);
mc.curveTo(r + x, Math.tan(Math.PI / 8) * r + y, Math.sin(Math.PI / 4) * r + x, Math.sin(Math.PI / 4) * r + y);
mc.curveTo(Math.tan(Math.PI / 8) * r + x, r + y, x, r + y);
mc.curveTo(-Math.tan(Math.PI / 8) * r + x, r + y, -Math.sin(Math.PI / 4) * r + x, Math.sin(Math.PI / 4) * r + y);
mc.curveTo(-r + x, Math.tan(Math.PI / 8) * r + y, -r + x, y);
mc.curveTo(-r + x, -Math.tan(Math.PI / 8) * r + y, -Math.sin(Math.PI / 4) * r + x, -Math.sin(Math.PI / 4) * r + y);
mc.curveTo(-Math.tan(Math.PI / 8) * r + x, -r + y, x, -r + y);
mc.curveTo(Math.tan(Math.PI / 8) * r + x, -r + y, Math.sin(Math.PI / 4) * r + x, -Math.sin(Math.PI / 4) * r + y);
mc.curveTo(r + x, -Math.tan(Math.PI / 8) * r + y, r + x, y);
counter++;
moveCircle(mc);
}
function moveCircle(mc:MovieClip):Void {
mc.ran = Math.floor(Math.random() * 10) + 1;
mc.onEnterFrame = function() {
this._y -= this.ran;
if (Math.abs(this._y) >= this.y - this.r) {
// Math.abs(this._y) >= this.y - this.r) is my cunning ploy to avoid any messing about with localToGlobal references and vice versa
this.removeMovieClip();
}
};
}
Thanks for the competition too. It’s been a lot of fun and also encouraged me too experiment with a few techniques I wouldn’t have otherwise :thumb: