//
/**
* Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/v0Hc
*/
// forked from amdmamdma's flash on 2011-6-5
package {
import flash.display.MovieClip;
import flash.text.TextField;
import flash.geom.Vector3D;
import flash.geom.Matrix3D;
import flash.events.Event;
import flash.geom.ColorTransform;
import flash.filters.BlurFilter;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.geom.Matrix;
import flash.display.Graphics;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
// 玉の直径
var size:uint = 50;
//背景生成
var sp02:Sprite = new Sprite();
var gr02:Graphics = sp02.graphics;
gr02.beginFill(0x000000);
gr02.drawRect(0, 0, 500, 500);
gr02.endFill();
addChild(sp02);
//元画像生成
var sp01:Sprite = new Sprite();
var gr01:Graphics = sp01.graphics;
var colors:Array = [0xffffff, 0x0000ff];
var alphas:Array = [1, 0];
var ratios:Array = [100, 255];
var mtr01:Matrix = new Matrix();
mtr01.createGradientBox(size, size);
gr01.beginGradientFill("radial", colors, alphas, ratios, mtr01);
gr01.drawCircle(size * 0.5, size * 0.5, size * 0.5);
gr01.endFill();
function xCreateBall(nCnt:uint = 1):Array{
var ar02:Array = [];
for(var i:uint = 0; i < nCnt; i ++){
//基本描画
var bd03:BitmapData = new BitmapData(sp01.width, sp01.height, true, 0x00000000);
bd03.draw(sp01);
var bm03:Bitmap = new Bitmap(bd03);
//エフェクト描画
var bd04:BitmapData = bd03.clone();
bd04.colorTransform(bd04.rect, new ColorTransform(1.5, 0, 0.5) );
var bm04:Bitmap = new Bitmap(bd04);
bm04.filters = [new BlurFilter(10, 10)];
bm04.blendMode = "add";
//bitmap格納用
var sp05:Sprite = new Sprite();
sp05.addChild(bm03);
sp05.addChild(bm04);
sp05.x = Math.cos(360 / nCnt * i * Math.PI / 180) * 150;
sp05.z = Math.sin(360 / nCnt * i * Math.PI / 180) * 150;
sp05.y = 100;
//
ar02.push(sp05);
//
// private function draw(e:Event):void
// {
// _canvas.draw(_view);
// _canvas.applyFilter( _canvas, _canvas.rect, op, blur );
// this.scroll( 2, 2 );
// this.scroll( -2, -2 );
// }
}
//
return ar02;
}
//全体格納用
var sp06:Sprite = new Sprite();
addChild(sp06);
const BALL_CNT:uint = 4;
var ar01:Array = xCreateBall(BALL_CNT);
for(var i:uint = 0; i < BALL_CNT; i ++){
sp06.addChild(ar01[i]);
}
var nX:Number = stage.stageWidth * 0.5;
var nY:Number = stage.stageHeight * 0.5;
sp06.x = nX;
sp06.y = nY;
//フレーム監視開始
addEventListener(Event.ENTER_FRAME, xFrame);
//test
var tex01:TextField = new TextField();
tex01.textColor = 0xffffff;
addChild(tex01);
//円運動
var nSpd:Number = 5;
var nDeg:Number = 0;
function xFrame(e:Event):void{
/*nDeg += nSpd;
nDeg = nDeg;// % 360;
sp06.rotationY = nDeg;*/
//sp06.rotationZ = nDeg / 2;
var ry:Number = (mouseX - nX) / (nX * 2) * 10;
//var rz:Number = (mouseY - nY) / (nY * 2) * 10;
sp06.rotationY += ry;
//sp06.rotationZ += rz;
for(var j:uint = 0; j < BALL_CNT; j ++){
ar01[j].rotationY = - sp06.rotationY;
}
}
}
}
}