In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

BetweenAS3 で onPlay が発生しない?

BetweenAS3 で serialTweens を使った時、それぞれの onPlay が発生しないっぽい?
コレは仕様?バグ?
Get Adobe Flash player
by bkzen 12 Mar 2012

    Talk

    ProjectNya at 13 Mar 2012 06:53
    TweenEvent使っても、onPlayが発生しませんね。仕様?
    bkzen at 13 Mar 2012 07:49
    やっぱりそうですよねー。 ありがとうございます。

    Tags

    Embed
/**
 * Copyright bkzen ( http://wonderfl.net/user/bkzen )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/4VeN
 */

package {
    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.events.Event;
    import org.libspark.betweenas3.BetweenAS3;
    import org.libspark.betweenas3.easing.Cubic;
    import org.libspark.betweenas3.tweens.ITween;
    import com.actionscriptbible.Example;
    public class FlashTest extends Example {
        public function FlashTest() {
            // write as3 code here..
            
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }
        
        private function init(e: Event = null): void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            //
            var itween: ITween;
            var shape: Shape = new Shape();
            shape.graphics.beginFill(0xFF);
            shape.graphics.drawRect(0, 0, 100, 100);
            var arr: Array = [];
            var i: uint, n: uint = 4;
            for (i = 0; i < n; i++) 
            {
                itween = BetweenAS3.tween(shape, { x: 100 * (i + 1) }, { x: 100 * i }, 1, Cubic.easeOut);
                itween.onComplete = itween.onPlay = trace;
                itween.onCompleteParams = ["onComplete", i];
                itween.onPlayParams = ["onPlay", i];
                arr.push(itween);
            }
            addChild(shape);
            itween = BetweenAS3.serialTweens(arr);
            itween.onPlay = itween.onComplete = trace;
            itween.onPlayParams = ["parent onPlay"];
            itween.onCompleteParams = ["parent onComplete"];
            itween.play();
        }
    }
}