vacuum
♥0 |
Line 55 |
Modified 2010-06-02 01:57:35 |
MIT License
archived:2017-03-20 00:55:29
ActionScript3 source code
/**
* Copyright gaina ( http://wonderfl.net/user/gaina )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/o34K
*/
package
{
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.filters.GlowFilter;
import flash.geom.Point;
[SWF(width=465,height=465,backgroundColor=0x000000,framerate=30)]
public class Vacuum extends Sprite
{
private var SCALE:Number = 1;
private var scaleAg:Number = 0.05;
//private var Vacuum_POINT:Point;
public function Vacuum():void
{
//Vacuum_POINT = new Point(stage.stageWidth / 2, stage.stageHeight / 2);
stage.addEventListener(MouseEvent.MOUSE_MOVE, ZUTTO_Vacuum);
stage.addEventListener(MouseEvent.CLICK, oneTimeVacuum);
}
private function ZUTTO_Vacuum(event:Event):void
{
draw();
}
private function oneTimeVacuum(event:MouseEvent):void
{
draw();
}
private function draw():void {
var sp:Sprite = new Sprite();
sp.graphics.clear();
sp.graphics.beginFill(Math.random()* 128 << 16);
sp.graphics.drawCircle(0, 0, 50);
sp.graphics.endFill();
var spGlow:GlowFilter = new GlowFilter(0xffffff, 0.5, 12, 12, 12, 2);
var arr:Array = [];
arr.push(spGlow);
sp.filters = arr;
sp.x = Math.random() * 865-200;
sp.y = Math.random() * 865-200;
addChild(sp);
sp.addEventListener(Event.ENTER_FRAME, loop);
}
private function loop(event:Event):void
{
event.target.scaleX -= 0.05;
event.target.scaleY -= 0.05;
event.target.x += (stage.mouseX - event.target.x) / 5;
event.target.y += (stage.mouseY - event.target.y) / 5;
//event.target.x += (Vacuum_POINT.x - event.target.x) / 5;
//event.target.y += (Vacuum_POINT.y - event.target.y) / 5;
if (event.target.scaleX < 0 || event.target.scaleY < 0)
{
event.target.removeEventListener(Event.ENTER_FRAME, loop);
removeChild(event.target as DisplayObject);
}
}
}
}