forked from: flash on 2010-7-14
// forked from kinoppy's flash on 2010-7-14
package {
import flash.events.Event;
import flash.display.Sprite;
import caurina.transitions.Tweener;
public class Something extends Sprite {
var container:Sprite = new Sprite();
var mcArr:Array = [];
var numTotal:Number = 69;
var color_arr:Array = ["0xFF0000", "0xFFFF00","0x3300CC","0x33FF33","0x0099CC","0x33CC99"];
public function Something() {
container.x = stage.stageWidth/2;
container.y = stage.stageHeight/2;
addChild(container);
createColor();
}
function createColor(){
for(var i:Number = 0; i < numTotal; i++){
var _c:Puyo = new Puyo(getColor(i));
_c.x = 0;
_c.y = 0;
_c.alpha = Math.random()*1;
_c.scaleX = _c.scaleY = 0.1;
container.addChild(_c);
mcArr.push(_c);
motion(i, _c.x, _c.y);
}
//container.addEventListener(Event.ENTER_FRAME, loop);
}
function getColor(order:Number){
var color:String = color_arr[Math.floor(Math.random()*6)];
return color;
}
function loop(e:Event){e.target.rotation+=1;}
function motion(num, xPos, yPos){
var _num = num;
var _alpha = Math.random()*1;
var _scale = 0.2;
var radian:Number = Math.PI * 2 / 12 * _num;
Tweener.addTween(mcArr[num], { x:130 * Math.cos(radian), y:130 * Math.sin(radian)+y ,scaleX:_scale, scaleY:_scale, alpha:_alpha, delay:5+0.02*num, time:0.5, transition: "easeOutBack", onComplete:function(){
// motion(_num, xPos, yPos);
}});
var colX = ( 50* (num % 10) )- stage.stageWidth/2;
var colY = (Math.floor(num / 10) * 50)-stage.stageHeight/2;
Tweener.addTween(mcArr[num], { x:colX, y:colY, delay:13+0.005*num*Math.random(), time:0.6, transition: "easeOutBack", onComplete:function(){
// motion(_num, xPos, yPos);
}});
Tweener.addTween(mcArr[num], { x:0, y:0, delay:18+0.005*num*Math.random(), time:0.8, transition: "easeInOutBack", onComplete:function(){
motion(_num, xPos, yPos);
}});
}
}
}
import flash.display.Sprite;
import flash.events.Event;
import flash.display.Graphics;
class Puyo extends Sprite
{
private const POINT_NUMBER:uint = 6;
private const RADIUS:uint = 80;
private var _centerX:uint, _centerY:uint;
private var _radian:Number;
private var _list:Array;
private var _apCanvas:Sprite;
private var _cpCanvas:Sprite;
private var _lineCanvas:Sprite;
var _color:Number;
public function Puyo(color)
{
_color = color;
_list = [];
_radian = 2 * Math.PI / POINT_NUMBER;
var _rc:Number;
var _d:Number;
var _cp:p;
for ( var i:int = 0; i < POINT_NUMBER; i++ )
{
_d = ( _radian * ( i + 1 ) ) - ( _radian * i );
_rc = RADIUS / Math.cos( _d * .5 );
_cp = new p( _centerX + _rc * Math.cos( _radian * ( i + 1 ) - _d * .5 ), _centerY + _rc * Math.sin( _radian * ( i + 1 ) - _d * .5 ) );
_list.push( _cp );
}
addEventListener( Event.ENTER_FRAME, loop, false, 0, true );
}
private function loop( e:Event ):void
{
var _cp:p;
var _np:p;
graphics.clear();
var _CC = _color;
graphics.beginFill( _CC , 1 );
graphics.moveTo( ( _list[0].x + _list[1].x ) * .5, ( _list[0].y + _list[1].y ) * .5 );
var i:int = POINT_NUMBER;
while ( --i >= 0 )
{
_cp = _list[i];
_cp._radX = _cp._ax * Math.PI / 180;
_cp._radY = _cp._ay * Math.PI / 180;
_cp.x = _cp._cx + _cp._rx * Math.sin( _cp._radX );
_cp.y = _cp._cy + _cp._ry * Math.sin( _cp._radY );
_cp._ax += _cp._sx;
_cp._ax %= 360;
_cp._ay += _cp._sy
_cp._ay %= 360;
_np = _list[ ( i + 1 ) % ( _list.length ) ];
graphics.lineStyle(.1, 0xCCCCCC);
graphics.curveTo( _np.x, _np.y, ( _cp.x + _np.x ) * .5, ( _cp.y + _np.y ) *.5 );
}
graphics.endFill();
}
}
import flash.geom.Point;
class p extends Point
{
public var _cx:Number, _cy:Number;
public var _radX:Number, _radY:Number;
public var _rx:Number, _ry:Number;
public var _ax:Number, _ay:Number;
public var _sx:Number, _sy:Number;
public function p( x:Number, y:Number )
{
this.x = _cx = x;
this.y = _cy = y;
_rx = ( Math.random() * 40 | 0 ) - 20;
_ry = ( Math.random() * 40 | 0 ) - 20;
_ax = _ay = 0;
_sx = Number( ( Math.random() * 10 + 1 ).toFixed(1) );
_sy = Number( ( Math.random() * 10 + 1 ).toFixed(1) );
}
}