Skip to main content
Participating Frequently
June 23, 2021
Answered

Can't acces movie clip method after updating createJS.

  • June 23, 2021
  • 1 reply
  • 378 views

Hello, I access the method  of a movieClip that has the name 'testMc' in the linkage, using this code :

 


var tst = new lib.testMc();
tst.testversion();

 

this code is in the first frame of the 'testMc' movie clip :

function testversion(){

console.log('from mc new version !!!!!!!!!!!!!!!!');

}
this .testversion =testversion ;

 

I get this error after updating to a new createjs version 1.0.0

 

Uncaught TypeError: this .testversion is not a function
at a.b._dispatchEvent (createjs.min.js:12)
at a.b._dispatchEvent (createjs.min.js:12)
at a.b.dispatchEvent (createjs.min.js:12)

    This topic has been closed for replies.
    Correct answer kglad

    you have, at least, 3 errors.

     

    1.  there shouldn't be a space between this and .testversion

    2.  testMc's timeline won't "run" unless it's added to the display.  ie, it's code won't execute

    3.  after it is added, there's a delay before it's first frame plays.

     

    use:

     

    var tst = new lib.testMc();

    this.addChild(tst);

    setTimeout(f,300);

    function f(){
    tst.testversion();

    // you can remove tst if it's not needed on stage.

    }

     

    1 reply

    kglad
    Community Expert
    kgladCommunity ExpertCorrect answer
    Community Expert
    June 24, 2021

    you have, at least, 3 errors.

     

    1.  there shouldn't be a space between this and .testversion

    2.  testMc's timeline won't "run" unless it's added to the display.  ie, it's code won't execute

    3.  after it is added, there's a delay before it's first frame plays.

     

    use:

     

    var tst = new lib.testMc();

    this.addChild(tst);

    setTimeout(f,300);

    function f(){
    tst.testversion();

    // you can remove tst if it's not needed on stage.

    }

     

    Participating Frequently
    June 24, 2021

    Thanks for your reply, in the original code there is no space after 'this' keyword and the movieClip was added to a container =), and you are right the setTimeout() resolves the problem.

     After the update to createjs 1.0.0 , I notice also that the method : stage.on("drawstart", functions, this, true)

    don't work and I have to replace it with setTimeout().

    kglad
    Community Expert
    Community Expert
    June 24, 2021

    you're welcome.