花火みたいな
package {
import caurina.transitions.Tweener;
import flash.display.Sprite;
import flash.events.TimerEvent;
import flash.filters.BitmapFilterQuality;
import flash.filters.BlurFilter;
import flash.geom.Point;
import flash.utils.Timer;
[SWF(backgroundColor="#000000")]
public class Explosion3 extends Sprite
{
private const RADIUS:uint = 200; //半径
private const MAX_NUM:uint = 30; //円の個数の最大値
private const SIZE:uint = 5; //円の大きさ
private const TIME:Number = 5; //Tweenerに指定する時間
private var filter:BlurFilter = new BlurFilter(4, 4, 1);
public function Explosion3()
{
var filter:BlurFilter = new BlurFilter(10, 10, BitmapFilterQuality.LOW); //ぼかしフィルターの作成
this.filters = [filter];
var timer:Timer = new Timer(200);
timer.addEventListener(TimerEvent.TIMER, explosion);
timer.start();
}
private function explosion(event:TimerEvent):void{ //円を飛び散らせる
var toPos:Point = new Point(); //円を飛ばす先の座標
var num:int = Math.floor(Math.random() * MAX_NUM); //円の個数
if(num < 5) num = 5;
var sp2:Sprite = new Sprite;
sp2.x = Math.random()* stage.stageWidth/2 + 100;
sp2.y = Math.random() * stage.stageHeight/2 + 100;
for(var i:int = 0; i < num; i++){
var sp:Sprite = new Sprite;
sp.graphics.beginFill(Math.random() * 0xFFFFFF); //描画
sp.graphics.drawCircle(0, 0, 5);
sp.graphics.endFill();
sp2.addChild(sp); //円を全てsp2の上に乗せる
toPos.x = RADIUS*Math.cos(2*Math.PI/num * i); //飛ばす先の座標計算
toPos.y = RADIUS*Math.sin(2*Math.PI/num * i);
Tweener.addTween(sp, {alpha:0, x:toPos.x, y:toPos.y, time:TIME}); //徐々に消えていく
}
addChild(sp2);
Tweener.addTween(sp2, {rotation: 360, time: TIME}); //sp2を一回転させる
}
}
}