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

timeline actions not working inside a function HTML Canvas

New Here ,
Sep 15, 2018 Sep 15, 2018

Hello all thanks for your time

I have a problem calling a timeline action inside a function, the movie clip i use in the function always comes out as undifined.

but when i call the action from within a button function it works as normal.

function reset() {

this.rhpump_mc.gotoAndStop(0);

console.log(2)

this.lhpump_mc.gotoAndPlay(51);

}

then i have a button

this.stop_btn.addEventListener("click", fl_MouseClickHandler.bind(this));

function fl_MouseClickHandler(e)

{

console.log(2)

reset()

}

console comes up with both movie clips undefined

but if i put the code all within the button like this .

this.stop_btn.addEventListener("click", fl_MouseClickHandler.bind(this));

function fl_MouseClickHandler(e)

{

this.rhpump_mc.gotoAndStop(0);

console.log(2)

this.lhpump_mc.gotoAndPlay(51);

}

I get no errors and it all functions normally

I must be doing something wrong .

Thank you for your help

PETER

291
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 , Sep 15, 2018 Sep 15, 2018

use reset.bind(this)() to call reset

Translate
Community Expert ,
Sep 15, 2018 Sep 15, 2018

use reset.bind(this)() to call reset

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
New Here ,
Sep 16, 2018 Sep 16, 2018

Thank you

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 ,
Sep 16, 2018 Sep 16, 2018

you're welcome.

(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)

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
New Here ,
Sep 16, 2018 Sep 16, 2018
LATEST

I understand I did make another posting before that explaining why I realise now after some research

that the "this" is not recognized inside the function when it was called as the "this " only has meaning to the object when it is binded ,but looks like it wasnt posted sorry about that.

Brg

Peter

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