oval
/**
* Copyright chimanaco ( http://wonderfl.net/user/chimanaco )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/4fY1
*/
package {
import flash.display.*;
import flash.events.*;
import flash.geom.Matrix;
[SWF(width = "465", height = "465", frameRate = "60", backgroundColor = "#000000")]
public class Oval extends Sprite {
private var _num:int = 100;
private var _centerX:Number = stage.stageWidth/2;
private var _centerY:Number = stage.stageHeight / 2;
private var _centerAngle:Number = 0;
private var _radiusX:Number = 150;
private var _radiusY:Number = 100;
private var _speed:Number = .01;
private var _acc:Number = 0;
private var _ballArray:Array = [];
private var _angleArray:Array = [];
public function Oval() {
var degree:Number;
var radians:Number;
var ball:Ball;
degree = 360 / _num;
for (var i:int = 0; i < _num; i++ ) {
ball = new Ball();
_ballArray[i] = ball;
radians = Math.PI / 180 * degree * i;
_angleArray[i] = radians;
addChild(ball);
}
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(e:Event):void {
var ball:Ball;
var angle:Number;
var radians:Number;
for (var i:int = 0; i < _num; i++ ) {
ball = _ballArray[i];
angle = _angleArray[i] +_acc;
radians = Math.PI / 180 * angle;
ball.x = _centerX + Math.sin(angle) * _radiusX;
ball.y = _centerY + Math.cos(angle) * _radiusY;
ball.scaleX = ball.scaleY = Math.tan(radians) * 1;
_acc += _speed;
}
}
}
}
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.*;
class Ball extends Sprite {
private static const _COLOR:uint = Math.random() * 0xFFFFFF;
private var cColor:uint;
public function Ball() {
graphics.beginFill(_COLOR, 1);
graphics.drawCircle(0, 0, 35);
graphics.endFill();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(e:Event):void {
cColor = Math.random() * 0xFFFFFF;
var ct:ColorTransform = new ColorTransform();
ct.color = cColor;
transform.colorTransform = ct;
}
}