class BubbleMaker { var my_cam; var pix; var balls:Array; var container:MovieClip; var active_mic; var inflated; var makingBubble; var score; var imgSource; public function BubbleMaker( ) { container = _root.createEmptyMovieClip( "container", 2 ); balls = []; inflated = 0; score = 0; imgSource = _root.video_mc; _root.createEmptyMovieClip("micro_mc", 3 ); active_mic = Microphone.get(); _root.attachAudio(active_mic); startCamera(); setInterval( this, "step", 30 ); } function step() { if ( makingBubble != undefined ) { inflated += ( active_mic.activityLevel + 1) / 20; makingBubble._xscale = makingBubble._yscale = inflated; if ( inflated > 100 ) { makingBubble.startSpeed( active_mic.activityLevel + 1 ); balls.push( makingBubble ); makingBubble = undefined; inflated = 0; } } else { makeBubble(); } pix.draw( imgSource ); for ( var i=balls.length-1; i>-1; i-- ) { balls[i].move(); var simple = Math.floor( pix.getPixel( balls[i]._x, balls[i]._y ) / 1000000 ); if ( simple < 5 ) { balls[i].kill(); balls.splice( i, 1 ); score++; _root.score_txt.text = score; } } } function startCamera() { my_cam = Camera.get(); _root.video_mc.my_video.attachVideo (my_cam ); pix = new _global.flash.display.BitmapData( 320, 240 ); } function makeBubble() { var depth = container.getNextHighestDepth(); var mc = container.attachMovie( "Ball", "ball"+depth, depth, { _x:_root.straw._x, _y:_root.straw._y, _xscale:0, _yscale:0 } ); makingBubble = mc; } }