flash on 2011-11-8
/**
* Copyright Heo.Wongeun ( http://wonderfl.net/user/Heo.Wongeun )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/rnaQ
*/
package {
import flash.filters.GlowFilter;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
import flash.geom.Transform;
import flash.net.FileFilter;
import flash.geom.Matrix;
import flash.filters.BlurFilter;
import flash.geom.ColorTransform;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.events.Event;
import flash.display.Shape;
import flash.display.Sprite;
[SWF(width="600", height="600", frameRate="40", backgroundColor="0x000000")]
public class FlashTest extends Sprite {
private var c:Shape;
public function FlashTest() {
// write as3 code here..
setBit();
circleCreate(30);
this.addEventListener(Event.ENTER_FRAME, onEnter);
}
private var objs:Array = new Array();
private var circleMovie:Sprite = new Sprite();
private var canvas:Bitmap;
private var bitData:BitmapData;
private var cs:Sprite;
private function setBit():void
{
bitData = new BitmapData(600,600,false,0x000000);
canvas = new Bitmap(bitData);
cs = new Sprite();
canvas.smoothing = true;
addChild(canvas);
//addChild(cs);
stage.addEventListener(MouseEvent.CLICK, stageClick);
}
private function circleCreate(n:uint):void
{
for(var i:uint=0; i<=n; i++)
{
c = new Shape();
c.graphics.beginFill(0xff0000,Math.random());
var r:Number = Math.random()*10+5
c.graphics.drawCircle(r*0.5,r*0.5,r);
c.x = Math.random()*600;
c.y = Math.random()*600;
c.graphics.endFill();
cs.addChild(c);
}
}
private function stageClick(e:MouseEvent):void
{
circleCreate(30);
}
private var n:Number = 0.01;
private var _x:Number;
private var _y:Number;
//private var colorTrans = new ColorTransform(1,1,1,0,0,0,0.5);
//private var blurF:BlurFilter = new BlurFilter(4,4,1);
private function onEnter(e:Event):void
{
//circleCreate(1);
bitData.lock();
//cs.x = Math.cos(n)*100;
bitData.draw(cs,new Matrix(1,0,0,1,0,0));
canvas.filters = [new BlurFilter(5,5)];
bitData.scroll(Math.cos(n),-1);
bitData.colorTransform(new Rectangle(0,0,600,6000),new ColorTransform(1,1,1,0.9,0,0,0,1));
canvas.filters = [new GlowFilter(16711680,1,5,5,3)];
//bitData.colorTransform = new ColorTransform(1, 1, 1, 1, 1, 0, 1, 0);
//bitData.colorTransform = new ColorTransform(1,1,1)
//canvas.applyFilter = [blurF];
n+=0.1;
bitData.unlock();
circlesMove()
}
private function circlesMove():void
{
for(var i:uint; i<cs.numChildren-1; i++)
{
var c = cs.getChildAt(i) as Shape;
//c.y+=(800-c.y)*0.5
c.scaleX += (2-c.scaleX)*0.5;
c.scaleY += (2-c.scaleY)*0.5;
c.alpha += (0-c.alpha)*0.2;
if(c.alpha < 0)cs.removeChild(c);
trace(cs.numChildren);
}
}
}
}