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

Can't play multiple Movie Clips on same frame

New Here ,
Mar 27, 2019 Mar 27, 2019

Hello,

I'm in the process of creating an interactive story using HTML 5 Canvas and have encountered an issue when using multiple Movie Clips on the same frame. The gist of my project is each scene is on one frame and all the animation is embedded into Movie Clips. The issue occurs when trying to add interactivity to the movie clips, the user clicks something and that symbol does an animation. At the moment only the last function will work no matter which function it is.

Here's my code;

this.stop(); //stops at this frame

this.midWave.addEventListener("click", fl_MouseClickHandler_2.bind(this));

function fl_MouseClickHandler_2()

{

this.Fish2.play();

}

this.Ship1.addEventListener("click", fl_MouseClickHandler_2.bind(this));

function fl_MouseClickHandler_2()

{

this.Ship1.play();

}

this.frontWave.addEventListener("click", fl_MouseClickHandler_2.bind(this));

function fl_MouseClickHandler_2()

{

this.Fish1.play();

}

Thanks in advance for reading!

Message was edited by: João César de Lima | Reason: font size too small

231
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 , Mar 27, 2019 Mar 27, 2019

Hi.

This is happening because you're redeclaring the fl_MouseClickHandler_2 function over and over again.

function fl_MouseClickHandler_2()

{

    this.Fish2.play();

}

function fl_MouseClickHandler_2()

{

    this.Ship1.play();

}

function fl_MouseClickHandler_2()

{

    this.Fish1.play();

}

Assign different names as you want different codes to run.

Regards,

JC

Translate
Community Expert ,
Mar 27, 2019 Mar 27, 2019

Hi.

This is happening because you're redeclaring the fl_MouseClickHandler_2 function over and over again.

function fl_MouseClickHandler_2()

{

    this.Fish2.play();

}

function fl_MouseClickHandler_2()

{

    this.Ship1.play();

}

function fl_MouseClickHandler_2()

{

    this.Fish1.play();

}

Assign different names as you want different codes to run.

Regards,

JC

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
LEGEND ,
Mar 27, 2019 Mar 27, 2019
LATEST

Or, better, just put all the movieclip actions in a single event handler.

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