No.01 - マウスについてくる何か
/**
* Copyright tnker ( http://wonderfl.net/user/tnker )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/7pOl
*/
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.utils.Timer;
public class Main extends Sprite {
private var sp:Circle;
private var isDown:Boolean = true;
public function Main() {
// write as3 code here..
this.addEventListener(Event.ENTER_FRAME, loop);
}
private function loop(e:Event):void
{
this.sp = new Circle(mouseX, mouseY);
this.addChild(sp);
this.addEventListener(Event.ADDED, init);
//this.sp.x += (this.mouseX - this.sp.x) * 0.1;
//this.sp.y += (this.mouseY - this.sp.y) * 0.1;
}
private function init(e:Event):void
{
var time:Timer = new Timer(2000, 1);
time.addEventListener(TimerEvent.TIMER_COMPLETE, del);
time.start();
removeEventListener(Event.ADDED, init);
}
private function del(e:TimerEvent):void
{
this.removeChildAt(0);
removeEventListener(TimerEvent.TIMER_COMPLETE, del);
}
}
}
import flash.display.Sprite;
import flash.events.Event;
import caurina.transitions.Tweener;
class Circle extends Sprite {
private var sp:Sprite;
private const SCALE_NUM:Number = 15;
public function Circle(x:Number, y:Number):void
{
this.sp = new Sprite();
this.sp.graphics.beginFill(0xFFFFFF * Math.random(), 0.3);
this.sp.graphics.drawCircle(x + randamFunc(SCALE_NUM), y + randamFunc(SCALE_NUM), 5 * Math.random());
this.sp.graphics.endFill();
addChild(sp);
Tweener.addTween(sp, { alpha:0, width:0, height:0, x:mouseX, y:mouseY, time:1, transition:"easeInQuart" } );
}
private function randamFunc(num:Number):Number
{
var n:Number = Math.random() * num;
var m:Number = Math.random() * num;
var l:Number = n - m;
return l;
}
}