flash on 2010-2-13
/**
* Copyright hazel_eyes ( http://wonderfl.net/user/hazel_eyes )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/u0tE
*/
package {
import flash.display.Sprite;
public class Circle extends Sprite {
private var num:int=30;
//コンストラクタ
function Circle() {
for (var i:int=0; i<num; i++) {
var myCircle:DrowCircle01 = new DrowCircle01((2*Math.PI/num)*i, num, 10*i, stage.stageHeight-50 - 15*i, i*0.05);
addChild(myCircle);
}
}
}
}
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
class DrowCircle01 extends Sprite {
private var degree:Number = 0;
private var radian:Number = 0;
private var speed:Number = 10;
private var radLimit:Number = 0;
private var size:Number = 0;
private var size1:Number = 0;
private var ang:Number = 0;
private var arrayNum:int;
private var vs:Number = 100;
private var tmp_x:Number = 0;
private var tmp_y:Number = 0;
private var tmp_z:Number = 0;
private var a:int = 0;
private var xRadius:Number = 250;
private var yRadius:Number = 20;
private var yCoor:Number;
private var sizeY:Number;
//コンストラクタ
public function DrowCircle01(angle:Number,num:int,xr:Number,yr:Number, si:Number) {
//xRadius = 250;
speed = chgDegree(speed);
radLimit = chgDegree(360);
ang = angle;
arrayNum = num - 1;
xRadius = xRadius-xr;
//yRadius = yRadius-yr;
yCoor = yr;
sizeY = si;
var ball:Sprite = new Sprite;
ball.graphics.beginFill(Math.random()*0xffffff);
ball.graphics.drawCircle(0, 0, 17);
ball.graphics.endFill();
ball.alpha = 0.9;
//ball.name = String(a++);
addChild(ball);
addEventListener(Event.ENTER_FRAME, frameMove);
}
public function frameMove(e:Event):void {
speed = chgDegree((stage.mouseX - stage.stageWidth/2)/50);
radian += speed;
radian %= radLimit;
tmp_x = Math.cos(radian + ang)*xRadius;
tmp_y = Math.sin(radian + ang)*yRadius;
tmp_z = Math.sin(radian + ang)* 50 + 50;
change3D(tmp_x, tmp_y, tmp_z);
scaleX = scaleY = size;
if (Math.sin(radian + ang)>=-0.3) {
Sprite(root).setChildIndex(this,0);
} else {
Sprite(root).setChildIndex(this,arrayNum);
}
}
public function chgDegree(deg:Number):Number {
var rad:Number;
rad = deg * Math.PI / 180;
return rad;
}
public function change3D(sx:Number, sy:Number, sz:Number):void {
x = sx*vs/(vs+sz) + stage.stageWidth/2;
y = -sy*vs/(vs+sz) + yCoor;
size = 2*vs/(vs+sz)-sizeY;
}
}