Skip to main content
Participating Frequently
September 15, 2018
Answered

timeline actions not working inside a function HTML Canvas

  • September 15, 2018
  • 1 reply
  • 362 views

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

    This topic has been closed for replies.
    Correct answer kglad

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

    1 reply

    kglad
    Community Expert
    kgladCommunity ExpertCorrect answer
    Community Expert
    September 15, 2018

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

    Participating Frequently
    September 16, 2018

    Thank you

    kglad
    Community Expert
    Community Expert
    September 16, 2018

    you're welcome.

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