Tweenerによるベジェ曲線のトゥイーン2
Tweener 1.31.74
wonderfl default screen size
package
{
import flash.display.Sprite;
import flash.events.Event;
//Tweener 1.31.74
import caurina.transitions.Tweener;
import caurina.transitions.properties.CurveModifiers;
//wonderfl default screen size
[SWF(width = 465, height = 465, frameRate = 30, backgroundColor = 0xFFFFFF)]
public class Main extends Sprite
{
private var ball:Sprite;
private var ballNum:int = 30;
private var array:Array = new Array();
private var sizeX:Number = stage.stageWidth;
private var sizeY:Number = stage.stageHeight;
private var base1:Object = { x:sizeX, y:sizeY, _bezier:[ { x:sizeX, y:0 }, { x:0, y:sizeY } ], time:5 };
private var base2:Object = { x:0, y:0, _bezier:[ { x:0, y:sizeY }, { x:sizeX, y:0 } ], time:5 }
public function Main():void
{
CurveModifiers.init();
graphics.lineStyle(1, 0x336699);
graphics.moveTo(0, 0);
graphics.curveTo(sizeX, 0, sizeX/2, sizeY/2);
graphics.curveTo(0, sizeY, sizeX, sizeY);
graphics.lineStyle();
for (var i:int = 0; i < ballNum; i++)
{
ball = new Sprite();
ball.graphics.beginFill(0x000000);
ball.graphics.drawCircle(0, 0, 5);
ball.graphics.endFill();
addChild(ball);
array.push(ball);
}
stage.addEventListener(Event.ENTER_FRAME, loopTween);
}
private function loopTween(e:Event):void
{
if (array[0].x == 0 && array[array.length - 1].x == 0)
{
for (var i:int = 0; i < array.length; i++)
{
Tweener.addTween(array[i], { base:base1, delay:i / 10 } );
}
}
if (array[0].x == sizeX && array[array.length - 1].x == sizeX)
{
for (var j:int = 0; j < array.length; j++)
{
Tweener.addTween(array[j], { base:base2, delay:j / 10 } );
}
}
}
}
}