Forked from: beinteractive's 2. Tween parameters with BetweenAS3 diff:9 forked from: 2. Tween parameters with BetweenAS3 hacker_yk666.. forked:0favorite:0lines:49license : All rights reserved modified : 2010-01-06 12:50:55 Embed Tweet // forked from beinteractive's 2. Tween parameters with BetweenAS3 package { import flash.display.Sprite; import flash.text.TextField; import flash.events.MouseEvent; import org.libspark.betweenas3.BetweenAS3; import org.libspark.betweenas3.tweens.ITween; import org.libspark.betweenas3.easing.*; public class Sample extends Sprite { public function Sample() { (addChild(new TextField()) as TextField).text = 'Click to start'; stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); } private function mouseUpHandler(e:MouseEvent):void { while (numChildren > 0) { removeChildAt(0); } var box1:Box = addNewBox(50); var box2:Box = addNewBox(150); var box3:Box = addNewBox(250); var box4:Box = addNewBox(350); // Parameters are: // .tween(Target, ToValues, FromValues, Time, Easing, Delay) //第一引数:ターゲットとなるオブジェクト //第二引数:tween先(Tweenerと同じように指定する) //第三引数:tween元(Tweenerにはなかった!) //第四引数:時間(BetweenAS3のデフォルトだと1.0、Tweenerだと0だったはず) //第五引数:easing(タイプを指定して、そのプロパティでin,outなどを指定) // Time setting: 2.5sec BetweenAS3.tween(box1, {x: 220}, null, 3).play(); // Easing setting: EaseOutBounce BetweenAS3.tween(box2, {x: 220}, null, 0.5, Bounce.easeOut).play(); // Easing with parameter BetweenAS3.tween(box3, {x: 220}, null, 0.5, Back.easeOutWith(1.9)).play(); // Delay setting: 1.0sec BetweenAS3.delay(BetweenAS3.tween(box4, {x: 220}, null, 1.5), 1.0).play(); } private function addNewBox(y:Number):Box { var box:Box = new Box(); box.x = 20; box.y = y; addChild(box); return box; } } } import flash.display.Sprite; internal class Box extends Sprite { public function Box() { graphics.beginFill(0); graphics.drawRect(-10, -10, 20, 20); graphics.endFill(); } } Code Fullscreen Preview Fullscreen play BetweenAS3.tween Back.easeOutWith Bounce.easeOut removeChildAt numChildren addEventListener MouseEvent.MOUSE_UP addChild TextField MouseEvent text Sprite Number