TypeError:createjs.Ticker.removeEventListener(...)未定义

时间:2018-01-05 09:11:27

标签: javascript html addeventlistener event-listener tweenjs

我在库中使用了easyjs和tweenjs库。在调用函数hsdissolve()之后,它似乎只包含了tweenjs库。

整个代码:

   var canvas;
    var stage;
    var tweens;
    var activeCount;
    var circleCount = 25;
    var text;

    function init() {
        canvas = document.getElementById("StartCanvas");
        stage = new createjs.Stage(canvas);
        stage.enableDOMEvents(true);
        tweens = [];
        stage.enableMouseOver(10);
        createjs.Touch.enable(stage);



        var image = new Image();
        image.src = "img/hs-logo-dark.png";

        image.onload = handleImageLoad;


    }

    function handleImageLoad(event) {
        var image = event.target;
        var hslogo = new createjs.Bitmap(image);
        hslogo.x = 230;
        hslogo.y = 150;
        stage.addChild(hslogo);
        stage.update();

        createjs.Ticker.addEventListener("tick", stage, false);
        hslogo.addEventListener("click", function() {

            createjs.Tween.get(hslogo).to({
                alpha: 0
            }, 1000).call(hsdissolve);
        });

        function hsdissolve() {
            //createjs.Ticker.removeEventListener("tick", stage, false);
            var Tneu = new createjs.Text("Neu", "36px Arial", "#777");
            Tneu.alpha = 0;
            stage.addChild(Tneu);
            stage.update();

            createjs.Ticker.addEventListener("trun", stage, false);
            Tneu.addEventListener("run", function(){

                createjs.Tween.get(Tneu).to({
                    alpha: 1
                }, 1000).call(tick);
            });


            }
            function tick() {
                createjs.Ticker.removeEventListener("trun", stage, false);

        }

hsdissolve的部分似乎并没有完成所有内容,但我无法记录任何内容。

可以在以下网址上重现: http://exodus-glitch.tk/easel/

有人可以告诉我我做错了吗?

0 个答案:

没有答案