flash on 2010-11-6
...
@author gaina
♥0 |
Line 66 |
Modified 2010-11-06 22:36:43 |
MIT License
archived:2017-03-20 00:54:39
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/kFPL
*/
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
/**
* ...
* @author gaina
*/
public class Main extends Sprite
{
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
stage.addEventListener(MouseEvent.MOUSE_MOVE, MouseEventHandler);
}
private function MouseEventHandler(e:MouseEvent):void
{
var p:Particles = new Particles();
p.x = mouseX;
p.y = mouseY;
addChild(p);
p.start();
p.addEventListener(Event.ENTER_FRAME, check);
}
private function check(e:Event):void
{
if (e.target.y > stage.stageHeight - 10) {
e.target.removeEventListener(Event.ENTER_FRAME, check);
e.target.eraze();
removeChild(e.target as Particles);
}
}
}
}
import flash.display.Sprite;
import flash.events.Event;
class Particles extends Sprite
{
public var vx:Number = 1;
public var vy:Number = 1;
public function Particles(color:uint=0)
{
graphics.beginFill(color, 1);
graphics.drawCircle(0, 0, 5);
graphics.endFill();
}
public function start():void
{
this.addEventListener(Event.ENTER_FRAME, loop);
}
private function loop(e:Event):void
{
this.y += vy;
vy += 0.5;
if (vy % 10 ==0) {
vy = 1;
}
}
public function eraze():void
{
this.removeEventListener(Event.ENTER_FRAME, loop);
graphics.clear();
}
}