Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Can't acces movie clip method after updating createJS.

Community Beginner ,
Jun 23, 2021 Jun 23, 2021

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)

314
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 24, 2021 Jun 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.

}

 

Translate
Community Expert ,
Jun 24, 2021 Jun 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.

}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 24, 2021 Jun 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().

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 24, 2021 Jun 24, 2021
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines