Between その2

今回はbettweenでtweenを
まとめてグループにして動かす場合と、
順番に動かす場合のサンプル。

test02.swf
Download this file

//ライブラリを読み込む
import org.libspark.betweenas3.BetweenAS3;
import org.libspark.betweenas3.tweens.ITween;
import org.libspark.betweenas3.easing.Quad;
import flash.events.MouseEvent;

//ステージに「btn_M」と「btn_Z」をおいてマウスイベントを設定。
//「btn_M」をクリックすると関数 move01 を実行。
//「btn_Z」をクリックすると関数 move02 を実行。
btn_M.addEventListener(MouseEvent.CLICK, move01);
btn_Z.addEventListener(MouseEvent.CLICK, move02);

//でその関数 move01とmove02を設定
function move01(eventObj:MouseEvent){
    var t01:ITween;
    t01 = BetweenAS3.parallel(
        BetweenAS3.tween(blue_box, {x: 360}, {x: 40}, 1, Quad.easeOut),
        BetweenAS3.tween(blue_box2, {x: 360}, {x: 40}, 1, Quad.easeOut),
        BetweenAS3.tween(blue_box3, {x: 360}, {x: 40}, 1, Quad.easeOut)
    )
    t01.play();
}

function move02(eventObj:MouseEvent){
    var t02:ITween;
    t02 = BetweenAS3.serial(
        BetweenAS3.tween(blue_box, {x: 360}, {x: 40}, 1, Quad.easeOut),
        BetweenAS3.tween(blue_box2, {x: 360}, {x: 40}, 1, Quad.easeOut),
        BetweenAS3.tween(blue_box3, {x: 360}, {x: 40}, 1, Quad.easeOut)
    )
    t02.play();
}

関数内の説明を簡単に。

ステージの上には「blue_box」「blue_box2」「blue_box3」を置いてます。

//「t01」というtweenを作って
var t01:ITween;

//t01に動きのグループを作ります。parallel(■■,○○,△△)と書くと
//■■と○○と△△を同時に実行してくれます。
//serial(■■,○○,△△)と書くと、■■と○○と△△を順番に実行してくれます。

t01 = BetweenAS3.parallel(
        BetweenAS3.tween(blue_box, {x: 360}, {x: 40}, 1, Quad.easeOut),
        BetweenAS3.tween(blue_box2, {x: 360}, {x: 40}, 1, Quad.easeOut),
        BetweenAS3.tween(blue_box3, {x: 360}, {x: 40}, 1, Quad.easeOut)
)

//最後に作ったtweenを再生。
t01.play();

超簡単。


Tags:

Comments are closed.

�g�уA�N�Z�X��� Google Analytics Alternative