1. //scripted Bubbles
  2. //quick 'n dirty code by Steffen Krause (info@fuzzyforge.com)
  3. Stage.showMenu = false;
  4. _global.bubbles_mc = this.createEmptyMovieClip("bubbles_mc", 1);
  5.  
  6. bubbles_mc.dot = function(caller:MovieClip, diameter:Number, color:Number){
  7.         caller.lineStyle(diameter,color,100);
  8.         caller.lineTo(.2,0);
  9.         }
  10.        
  11. bubbles_mc.swing = function(caller:MovieClip){
  12.         caller._x = caller.startx + Math.sin( Math.PI / 180 * caller.xcounter ) * caller.area;
  13.         caller._y = caller.starty + Math.sin( Math.PI / 180 * caller.ycounter ) * caller.area;
  14.         caller.xcounter += caller.xrate;
  15.         caller.ycounter += caller.yrate;
  16.         if(caller.xcounter>360){caller.xcounter-=360;} //lets keep the values small
  17.         if(caller.ycounter>360){caller.ycounter-=360;}
  18.         for(var i:Number=0;i<caller.childs.length;i++){
  19.                 caller.childs[i]._x = caller._x;
  20.                 caller.childs[i]._y = caller._y;
  21.                 }
  22.         }
  23.        
  24. bubbles_mc.addBall = function(x:Number, y:Number, scale:Number, counter:Number){
  25.         var blackLevel:Number = 2;
  26.         var blueLevel:Number  = 200;
  27.         var whiteLevel:Number = 400;
  28.         var bb:MovieClip = this.createEmptyMovieClip("bb" + counter, blackLevel + counter);
  29.         this.dot(bb, scale, 0x000000);
  30.         bb._x = x;
  31.         bb._y = y;
  32.         var gb:MovieClip = this.createEmptyMovieClip("gb" + counter, blueLevel + counter);
  33.         this.dot(gb, .9 * scale, 0xA8EEFF);
  34.         gb._x = x;
  35.         gb._y = y;
  36.         var wb:MovieClip = this.createEmptyMovieClip("wb" + counter, whiteLevel + counter);
  37.         this.dot(wb, .8 * scale, 0xFFFFFF);
  38.         wb._x = x;
  39.         wb._y = y;
  40.         wb.childs = [gb,bb];
  41.         wb.startx = x;
  42.         wb.starty = y;
  43.         wb.area = 20 + Math.ceil( Math.random() * 50);
  44.         wb.xrate = 6 + Math.ceil( Math.random() * 12);
  45.         wb.yrate = 5 + Math.ceil( Math.random() * 10);
  46.         wb.xcounter = 0;
  47.         wb.ycounter = 0;
  48.         wb.onEnterFrame = function(){ bubbles_mc.swing(this); };
  49.         }
  50.        
  51. bubbles_mc.setup = function(){
  52.         for(i=0;i<20;i++){
  53.                 x = 115 + Math.ceil(Math.random()*200);
  54.                 y = 115 + Math.ceil(Math.random()*200)
  55.                 scale = 30 + Math.ceil(Math.random()*70);
  56.                 this.addBall(x,y,scale,i);
  57.                 }
  58.         }
  59.        
  60. bubbles_mc.onKeyDown   = function(){ this.setup(); }
  61. bubbles_mc.onMouseDown = function(){ this.setup(); }
  62. Key.addListener(bubbles_mc);
  63. bubbles_mc.setup();
  64.  
  65. //let it glow
  66. import flash.filters.GlowFilter;
  67. var filter:GlowFilter = new GlowFilter(0x33CCFF, .4, 2228, 3, 3, true, false);
  68. bubbles_mc.filters = [filter];
  69. stop()