BetweenAS3お試し-基本とonComplete
...
@author izm_design
/**
* Copyright alterna_in ( http://wonderfl.net/user/alterna_in )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/cB4f
*/
package
{
import flash.display.Sprite;
import flash.events.Event;
import org.libspark.betweenas3.BetweenAS3;
import org.libspark.betweenas3.tweens.IObjectTween;
import org.libspark.betweenas3.events.TweenEvent;
/**
* ...
* @author izm_design
*/
[SWF(backgroundColor="#FFFFFF", frameRate=30)]
public class Main extends Sprite
{
public var sp:Sprite;
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
sp = new Sprite();
sp.graphics.beginFill(0xff0000);
sp.graphics.drawRect(10, 10, 10, 10);
sp.graphics.endFill();
addChild(sp);
//IObjectTweenでtweenをつくる
var objTween:IObjectTween = BetweenAS3.tween(sp, { x:100 } );
//とりあえずCOMPLETEとかでイベントハンドラを設定しておく
objTween.addEventListener(TweenEvent.COMPLETE, onComplete);
objTween.play();
}
private function onComplete(e:TweenEvent):void
{
//e.target.targetでtweenされてるターゲット(sp)が参照できる。
//ちなみにe.targetはobjTweenになる。
BetweenAS3.tween(e.target.target, { y:100 } ).play();
}
}
}