Flashの宝石箱やー
/**
* Copyright _wonder ( http://wonderfl.net/user/_wonder )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/fODG
*/
package {
import flash.display.Sprite;
import flash.events.*;
[SWF( width="465", height="465", backgroundColor="0x000000", frameRate="30" )]
public class Jewel extends Sprite {
public function Jewel() {
stage.addEventListener(Event.ENTER_FRAME, make_ball);
}
private function make_ball(e:Event):void {
var ball:Ball = new Ball();
ball.x = stage.mouseX;
ball.y = stage.mouseY;
ball.init();
ball.move();
addChild( ball );
}
}
}
import flash.display.*;
import flash.events.*;
internal class Ball extends Sprite {
private var ball:Sprite;
private var radius:Number = 5;
private var g:Number = Math.random()+0.2;
private var speed:Number = -10;
private var color:int = Math.random()*0xFFFFFF;
private var perX:Number = Math.random()*10-5;
public function init():void {
ball = new Sprite();
ball.graphics.lineStyle(1,color);
ball.graphics.beginFill(color,0.2);
ball.graphics.drawCircle(0,0,5);
ball.graphics.endFill();
addChild( ball );
}
public function move():void {
addEventListener(Event.ENTER_FRAME, fall);
}
public function move_stop():void {
removeEventListener(Event.ENTER_FRAME, fall);
}
private function fall(e:Event):void {
speed += g;
this.y += speed;
this.x += perX;
if(this.y > stage.stageHeight+radius){
move_stop();
var parentObj:Object = Object(parent);
parentObj.removeChild(this);
}
}
}