Fall of ball on 2012-8-28
Please click any ball.
♥0 |
Line 56 |
Modified 2012-08-28 01:56:05 |
MIT License
archived:2017-03-20 03:09:40
ActionScript3 source code
/**
* Copyright Seiya.Kai ( http://wonderfl.net/user/Seiya.Kai )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/qTcz
*/
package
{
import flash.display.Sprite;
import flash.events.Event;
[SWF(width="600", height="600", frameRate="60")]
public class Main extends Sprite
{
private static const WIDTH:Number = 600;
private const HEIGHT:Number = 600;
public function Main()
{
setCircle();
}
private function setCircle():void
{
for (var i:int = 0; i < 50; i++)
{
var c:Sprite = new Circle(Math.random()*0xFFFFFF);
c.x = Math.random()*WIDTH;
c.y = Math.random()*HEIGHT;
addChild(c);
}
}
}
}
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
class Circle extends Sprite
{
private var R:Boolean = false, L:Boolean = false;
private var mFlag:Boolean = false;
private var vx:Number,vy:Number,g:Number=0.5;
public function Circle(color:uint=0xFF0000):void{
graphics.lineStyle(5,color);
graphics.beginFill(color,0.4);
graphics.drawCircle(0,0,40);
graphics.endFill();
vx = (Math.random()*2-1)*10;
vy = -Math.random()*10;
addEventListener(Event.ENTER_FRAME,onEnterFrame);
addEventListener(MouseEvent.CLICK,onClick);
}
private function onEnterFrame(event:Event):void
{
if(!mFlag) return;
vy += g;
this.x += vx;
this.y += vy;
}
private function onClick(e:MouseEvent):void
{
mFlag = true;
stage.focus = this;
}
}