Mouse move effect
...
@author pixelDevil
/**
* Copyright PixelDevil ( http://wonderfl.net/user/PixelDevil )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/iwsv
*/
package {
import flash.display.Sprite;
import flash.display.Stage;
import flash.ui.Mouse;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.display.*;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.display.Bitmap;
/**
* ...
* @author pixelDevil
*/
public class MouseEffect extends Sprite {
/*creating a new shape*/
var blackShape:Shape;
// CONSTRUCTOR
public function MouseEffect ():void {
stage.addEventListener(MouseEvent.MOUSE_MOVE, startTrailer);
}
private function startTrailer(e:MouseEvent):void {
/* Create a new blackShape object */
blackShape= new Shape();
blackShape.graphics.beginFill(0x00000); // color balck
blackShape.graphics.drawRect(0, 0, 10, 10); // size 10x10
/* Position */
blackShape.x = mouseX + Math.random() * blackShape.width;
blackShape.y = mouseY - Math.random() * blackShape.height;
/* Add to Stage */
stage.addChild(blackShape);
/* Add Listener to Animate function */
blackShape.addEventListener(Event.ENTER_FRAME, animate);
}
// FUNCTION ENTERFRAME
private function animate(e:Event):void {
/* Alpha */
e.currentTarget.alpha -= 0.05;
/* If blackShape is no longer visible, remove it */
if (e.target.alpha <= 0){
e.currentTarget.removeEventListener(Event.ENTER_FRAME, animate);
stage.removeChild(e.currentTarget as Sprite);
}
/* Scale */
e.currentTarget.scaleX -= 0.1;
e.currentTarget.scaleY -= 0.1;
/* Y Position */
e.currentTarget.y += 3;
}
}
}