bubble with bezier curve of Tweener (090226)
package {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.filters.*;
import flash.utils.*;
import caurina.transitions.Tweener;
import caurina.transitions.properties.CurveModifiers;
[SWF(backgroundColor="#000000", frameRate=30)]
public class bezier extends MovieClip {
private var stageW:Number = stage.stageWidth;
private var stageH:Number = stage.stageHeight;
public function bezier() {
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
CurveModifiers.init();
var dotTimer:Timer = new Timer(50);
dotTimer.addEventListener("timer", drawDot);
dotTimer.start();
// take a capture after 30 sec
Wonderfl.capture_delay( 30 );
}
public function drawDot(event:TimerEvent):void {
var dotSize:Number = Math.random()*5;
var dotColor:Number = Math.random()*(0xffffff);
// ドット作成
var dot:Sprite = new Sprite();
dot.graphics.beginFill(dotColor);
dot.graphics.drawCircle(0, 0, dotSize);
dot.graphics.endFill();
// ドットのMC
var dot_mc:MovieClip = new MovieClip();
dot_mc.x = 15;
dot_mc.y = stageH/2;
dot_mc.alpha = 0.2;
dot_mc.addChild(dot);
addChild(dot_mc);
xMove(dot_mc, dotColor);
}
public function xMove(dot_mc:MovieClip, dotColor:Number):void {
// ベジェコントロールポイント用の乱数
var bezierY:Number = Math.random()*stageH;
// Tweenerのパラメータ
Tweener.addTween(dot_mc, {
x:stageW-15,
y:stageH/2,
scaleX:dot_mc.width*1.5,
scaleY:dot_mc.height*1.5,
alpha:0.7,
_bezier:[{x:15, y:225}, {x:stageW/2, y:bezierY}, {x:stageW-15, y:225}],
time:30,
transition:"linear",
onComplete:xEnd,
onCompleteParams:[dot_mc]
});
// Tween終了時にMCを消す
function xEnd(targetDot:MovieClip):void {
removeChild(targetDot);
}
}
}
}