円があったら落下させざるを得ない
// forked from ahchang's RainbowColorの七宝模様
// forked from ahchang's flash on 2009-5-1 RandomColorなCircleを並べてみた
package {
import flash.display.Sprite;
import frocessing.color.ColorHSV;
[SWF(width=465, height=465, frameRate=30, backgroundColor=0xffffff)]
public class CircleNest extends Sprite
{
private var hsv:ColorHSV;
private var i:int;
private var j:int;
private var cx:int;
private var cy:int;
private var r:int=30;
private var t:int=0;
public function CircleNest()
{
init();
}
private function init():void
{
t++;
for (i=0; i<15; i++)
{
cx = i*r*1.42;
for (j=0; j<12; j++)
{
cy = j*r*1.42;
var circle:ColorCircle = new ColorCircle(cx,cy,r,0.4,new ColorHSV(cx+cy, 1, 1, 1),((i*3)+(12-j)*8) );
addChild(circle);
}
}
}
}
}
import flash.display.Sprite;
import frocessing.color.ColorHSV;
import flash.events.*;
class ColorCircle extends Sprite
{
private var vy:Number=0;
private var py:Number=0;
private var time:int = 0;
private var stat:int = 0;
public function ColorCircle( cx:int,cy:int,cr:int,cal:Number,hsv:ColorHSV ,t:int)
{
x = cx;
py = cy;
y = cy - 630;
graphics.beginFill(hsv.value);
graphics.drawCircle(0,0,cr);
alpha = cal;
time = t;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(e:Event):void
{
// 汚いなさすがswitchきたない
// 処理まとめられるだろうけどめんどうだしいいや
switch( stat )
{
case 0:
if(time == 0 )
{
stat = 1;
vy = 0;
}
--time;
break;
case 1:
vy += 0.5;
y += vy;
if( y >= py )
{
y=py;
time = 120;
stat=2;
}
break;
case 2:
if( time == 0 )
{
stat = 3;
vy = 0;
}
--time;
break;
case 3:
vy += 0.5;
y += vy;
if( y >= py+630 )
{
y=py-630;
time = 120;
stat=0;
}
break;
}
return;
}
}