forked from: float cross
2009.09.29 effect追加
/**
* Copyright geta ( http://wonderfl.net/user/geta )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/dvdd
*/
// forked from iong's float cross
package
{
/* 2009.09.29 effect追加 */
import flash.display.Sprite;
[SWF(width="465", height="465", backgroundColor="0x003366", frameRate="30")]
public class Rad extends Sprite
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
import flash.display.BlendMode;
import flash.geom.Point;
import flash.filters.BlurFilter;
import flash.display.StageQuality;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
var Sp:Sprite;
var SpR:Sprite;
var cv:BitmapData;
var iP1:uint = 2;
var iP2:uint = 1;
public function Rad():void
{
stage.quality = StageQuality.LOW;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
cv = new BitmapData(465, 465, true, 0x000000);
addChild(new Bitmap(cv));
SpR = new Sprite();
addChild(SpR);
addEventListener(Event.ENTER_FRAME, makeAll);
}
private function makeAll(e:Event):void
{
Sp = new SPPiece(iP1, iP2);
Sp.scaleX = Math.round(Math.random()*1400)/100;
Sp.scaleY = Sp.scaleX;
Sp.alpha = 0.5;
//Sp.rotation = Math.round(Math.random()*360);
Sp.x = Math.round(Math.random()*465);
Sp.y = stage.stageHeight + 50;
SpR.addChild(Sp);
Sp.addEventListener(Event.ENTER_FRAME, movePiece);
cv.draw(SpR, null, null, BlendMode.OVERLAY);
cv.applyFilter(cv, cv.rect, new Point(), new BlurFilter(16,16));
}
private function movePiece(e:Event):void
{
e.target.rotation+=5;
e.target.x += 2 * Math.cos(Math.PI/180*e.target.rotation) + (mouseX-stage.stageWidth/2)/30;
e.target.y -= 2 + e.target.scaleX/2;
if(e.target.x>=stage.stageWidth+e.target.width) e.target.x -= stage.stageWidth + 100;
if(e.target.x<=0-e.target.width) e.target.x += stage.stageWidth + 100;
if(e.target.y<=-(e.target.height)){
e.target.removeEventListener(Event.ENTER_FRAME, movePiece);
SpR.removeChild(Sprite(e.target));
}
}
}
}
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
class SPPiece extends Sprite
{
public function SPPiece(n1:uint, n2:uint):void
{
var tBD:BitmapData = new BitmapData(n1*2, n1*2, true, 0);
var tSP:Sprite = new Sprite();
tSP.addChild(new Bitmap(tBD));
var iC:int = retC(100);
for(var i:int=0; i<n1*2; i++){
for(var k:int=0; k<n1*2; k++){
if( (i<n2 && k<n2) || (i<n2 && k>=n1*2-n2) || (i>=n1*2-n2 && k<n2) || (i>=n1*2-n2 && k>=n1*2-n2)){
//tBD.setPixel(i, k, 0x000000);
}else tBD.setPixel32(i, k, iC);
}
}
tSP.x-=n1;
tSP.y-=n1;
addChild(tSP);
}
// ランダムカラーをreturn
private function retC(n:uint):int
{
var ofR:int = n+Math.round(Math.random()*(255-n));
var ofG:int = n+Math.round(Math.random()*(255-n));
var ofB:int = n+Math.round(Math.random()*(255-n));
return parseInt("0xff"+ ofR.toString(16)+ ofG.toString(16) + ofB.toString(16));
}
}