Filters on 2012-1-17
/**
* Copyright xiaoxiao ( http://wonderfl.net/user/xiaoxiao )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/vFbB
*/
package
{
import flash.events.MouseEvent;
import flash.display.Sprite;
import flash.events.Event;
import flash.filters.BevelFilter;
import flash.filters.BlurFilter;
import flash.filters.ColorMatrixFilter;
import flash.filters.DropShadowFilter;
import flash.filters.GlowFilter;
public class FlashTest extends Sprite
{
private var view_spr:Sprite = new Sprite;
private var rotationSpeeds:Array = [];
private var sprCount:int = 10;
public function FlashTest()
{
addChild(view_spr);
var s:Number = 64;
var a:Number = -s/2*255;
var matrix:Array = [
s,0,0,0,a,
0,s,0,0,a,
0,0,s,0,a,
0,0,0,s,a];
view_spr.filters = [new BlurFilter(32,32,1),new ColorMatrixFilter(matrix),new BevelFilter(10,45,0xFFFFFF,.6,0,.6,16,16,3),new GlowFilter(0,1,2,2,8,1,true),new DropShadowFilter(4,45,0,.7)];
for(var i:int = 0;i<sprCount;i++)
{
rotationSpeeds[i] = Math.random()*10-5;
var spr:Sprite = new Sprite;
spr.graphics.beginFill(0x0066FF);
var w:Number = Math.random()*170+40;
var h:Number = Math.random()*170+40;
spr.x = Math.random()*stage.stageWidth;
spr.y = Math.random()*stage.stageHeight;
spr.graphics.drawRect(-w/2,-h/2,w,h);
spr.rotation = Math.random()*360;
view_spr.addChild(spr);
}
addEventListener(Event.ENTER_FRAME,onEnterFrame);
stage.addEventListener(MouseEvent.MOUSE_MOVE,onMouseMove);
}
private function onEnterFrame(e:Event):void {
for(var i:int = 0;i<sprCount;i++)
view_spr.getChildAt(i).rotation += rotationSpeeds[i];
}
private function onMouseMove(e:MouseEvent):void {
view_spr.getChildAt(0).x = mouseX;
view_spr.getChildAt(0).y = mouseY;
}
}
}