forked from: forked from: 光る玉
package
{
import caurina.transitions.Tweener;
import caurina.transitions.properties.CurveModifiers;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.BlendMode;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.filters.BlurFilter;
import flash.filters.ColorMatrixFilter;
import flash.geom.Point;
import flash.utils.Timer;
import flash.media.*;
import flash.system.*;
[SWF(width="465", height="465", backgroundColor="0x000000", frameRate="40")]
public class bezier extends Sprite
{
private var bmpd:BitmapData;
private var colorMatrix:ColorMatrixFilter;
private var Blur:BlurFilter;
private var myMic:Microphone;
private var sprites:Array;
public function bezier()
{
bmpd = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0x00000000);
var bmp:Bitmap = new Bitmap(bmpd);
addChild(bmp);
sprites = [];
var timer:Timer = new Timer(250);
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.start();
CurveModifiers.init();
colorMatrix = new ColorMatrixFilter([0.99, 0, 0, 0, 1, 0, 0.99, 0, 0, 1, 0, 0, 0.99, 0, 1, 0, 0, 0, 0.99]);
Blur = new BlurFilter(8, 8, 1);
addEventListener(Event.ENTER_FRAME, onFrame);
myMic = Microphone.getMicrophone();
//Security.showSettings(SecurityPanel.MICROPHONE);
myMic.setLoopBack(true);
myMic.setUseEchoSuppression(true);
}
private function onTimer(e:TimerEvent):void
{
var sp:Sprite = new Sprite();
sp.graphics.beginFill(0xffffff * Math.random(), 1);
sp.graphics.drawCircle(0, 0, 20 * Math.random() + 4);
sp.graphics.endFill();
var spHolder:Sprite = new Sprite();
addChild(spHolder);
spHolder.addChild(sp);
spHolder.x = -10;
spHolder.y = 495*Math.random()-30;
spHolder.scaleX = spHolder.scaleY = spHolder.alpha = 0;
spHolder.filters = [new BlurFilter(32, 32, 1)];
spHolder.blendMode = BlendMode.ADD;
sprites.push(sp);
var t:Number=(13 - 8) * Math.random() + 8;
Tweener.addTween(spHolder, {alpha:0.5, scaleX:1, scaleY:1, time:1});
Tweener.addTween(spHolder, {x:600, y:465*Math.random(), _bezier:[{x:232.5, y:665*Math.random()-100}], time:t})
Tweener.addTween(spHolder, {alpha:0, scaleX:0, scaleY:0, time:1, delay:t-2, onComplete:function():void
{
spHolder.removeChild(sp);
sp.filters = [];
sp.graphics.clear();
sp = null;
removeChild(spHolder);
spHolder = null;
}});
}
private function onFrame(e:Event):void
{
bmpd.draw(this);
bmpd.applyFilter(bmpd, bmpd.rect, new Point(0, 0), Blur);
bmpd.applyFilter(bmpd, bmpd.rect, new Point(0, 0), colorMatrix);
for each(var item:Sprite in sprites)
{
item.y += myMic.activityLevel*20 * (Math.random()-0.50) ;
}
}
}
}