forked from: forked from: flash on 2009-3-16
// forked from hirou's forked from: flash on 2009-3-16
// forked from anabebe's flash on 2009-3-16
package {
import caurina.transitions.Tweener;
import flash.display.Sprite;
import flash.events.*;
import flash.filters.BitmapFilterQuality;
import flash.geom.Point;
[SWF(backgroundColor="#000000")]
public class Explosion3 extends Sprite
{
private const RADIUS:uint = 40; //半径
private const MAX_NUM:uint = 30; //円の個数の最大値
private const SIZE:uint = 2; //円の大きさ
private const TIME:Number = 4; //Tweenerに指定する時間
public function Explosion3()
{
addEventListener(Event.ENTER_FRAME, explosion);
}
private function explosion(e:Event):void{ //円を飛び散らせる
var toPos:Point = new Point(); //円を飛ばす先の座標
var num:int = Math.floor(Math.random() * MAX_NUM); //円の個数
if(num < 2) num = 2;
var sp2:Sprite = new Sprite;
sp2.x = Math.random()* stage.stageWidth/2 + 100;
sp2.y = Math.random() * stage.stageHeight/2 + 150;
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を一回転させる
}
}
}