-
//scripted Bubbles
-
//quick 'n dirty code by Steffen Krause
(info@fuzzyforge.com)
-
Stage.showMenu
= false;
-
_global.bubbles_mc
= this.createEmptyMovieClip("bubbles_mc",
1);
-
-
bubbles_mc.dot = function(caller:MovieClip,
diameter:Number, color:Number){
-
caller.lineStyle(diameter,color,100);
-
caller.lineTo(.2,0);
-
}
-
-
bubbles_mc.swing = function(caller:MovieClip){
-
caller._x
= caller.startx + Math.sin(
Math.PI / 180
* caller.xcounter )
* caller.area;
-
caller._y
= caller.starty + Math.sin(
Math.PI / 180
* caller.ycounter )
* caller.area;
-
caller.xcounter
+= caller.xrate;
-
caller.ycounter
+= caller.yrate;
-
if(caller.xcounter>360){caller.xcounter-=360;}
//lets keep the values small
-
if(caller.ycounter>360){caller.ycounter-=360;}
-
for(var
i:Number=0;i<caller.childs.length;i++){
-
caller.childs[i]._x
= caller._x;
-
caller.childs[i]._y
= caller._y;
-
}
-
}
-
-
bubbles_mc.addBall = function(x:Number,
y:Number, scale:Number,
counter:Number){
-
var
blackLevel:Number = 2;
-
var
blueLevel:Number = 200;
-
var
whiteLevel:Number = 400;
-
var
bb:MovieClip = this.createEmptyMovieClip("bb"
+ counter, blackLevel + counter);
-
this.dot(bb,
scale, 0x000000);
-
bb._x
= x;
-
bb._y
= y;
-
var
gb:MovieClip = this.createEmptyMovieClip("gb"
+ counter, blueLevel + counter);
-
this.dot(gb,
.9 * scale, 0xA8EEFF);
-
gb._x
= x;
-
gb._y
= y;
-
var
wb:MovieClip = this.createEmptyMovieClip("wb"
+ counter, whiteLevel + counter);
-
this.dot(wb,
.8 * scale, 0xFFFFFF);
-
wb._x
= x;
-
wb._y
= y;
-
wb.childs
= [gb,bb];
-
wb.startx
= x;
-
wb.starty
= y;
-
wb.area
= 20 + Math.ceil(
Math.random()
* 50);
-
wb.xrate
= 6 + Math.ceil(
Math.random()
* 12);
-
wb.yrate
= 5 + Math.ceil(
Math.random()
* 10);
-
wb.xcounter
= 0;
-
wb.ycounter
= 0;
-
wb.onEnterFrame
= function(){
bubbles_mc.swing(this);
};
-
}
-
-
bubbles_mc.setup = function(){
-
for(i=0;i<20;i++){
-
x = 115 + Math.ceil(Math.random()*200);
-
y = 115 + Math.ceil(Math.random()*200)
-
scale = 30 + Math.ceil(Math.random()*70);
-
this.addBall(x,y,scale,i);
-
}
-
}
-
-
bubbles_mc.onKeyDown =
function(){
this.setup();
}
-
bubbles_mc.onMouseDown = function(){
this.setup();
}
-
Key.addListener(bubbles_mc);
-
bubbles_mc.setup();
-
-
//let it glow
-
import flash.filters.GlowFilter;
-
var filter:GlowFilter = new
GlowFilter(0x33CCFF, .4,
22, 28, 3,
3, true, false);
-
bubbles_mc.filters = [filter];
-
stop()