Search code examples
variablescreatejstweentweenjs

how can I use a variable to set tween duration?


var root = this;
function go(){
    createjs.Tween
        .get(root.mvpano, {override:true} )
        .to({x:100}, duration: **here I want  to place a variable**, createjs.Ease.cubicOut);
};

So that... is posible to use a variable to set the tween duration?


Solution

  • You can put a variable in as any property (see this fiddle). Note that once you create the tween, if the variable changes, the tween will not.

    function go(duration, position){
        createjs.Tween
            .get(s, {override:true} )
            .to({x:position}, duration, createjs.Ease.cubicOut);
    };