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

HTML5

Explorer ,
Jun 18, 2024 Jun 18, 2024

Hi guys, trying a new solution to a problem. Is it possible to have different movies play on the main timeline depending on which frame the main timeline is currently on when a button is clicked? This is the code I have tried but not working. Any help would be greatly apreciated!

 

this.fire2.addEventListener("click", fire.bind(this));
function fire()
{

 

if (this.currentFrame > 1 && this.currentFrame < 14)
{
this.shit2.visible=true;
this.shit2.play();
}

else if (this.currentFrame > 13 && this.currentFrame < 18)
{
this.pepe.visible=false;
this.shit16.visible=true;
this.shit16.play();
}

 

else (this.currentFrame > 17 && this.currentFrame <25)
{
this.shit19.visible=true;
this.shit19.play();
}


}

384
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

Explorer , Jun 18, 2024 Jun 18, 2024

Thanks for the reply! I don't know what was wrong but it's working now.

BUT when using the if, if else and else statements, the movieClips were playing over each other in certain parts.

SO I went with 3 if statments instead and now they run smooth and separated? Don't know why.

So ->

this.fire2.addEventListener("click", fire.bind(this));
function fire()
{
//early shot
if (this.currentFrame > 1 && this.currentFrame < 14)
{
this.shit2.visible=true;
this.shit2.play();
}
//sweet shot
if (this.currentFrame > 13 &&

...
Translate
Community Beginner ,
Jun 18, 2024 Jun 18, 2024

is this.fire2 on the main timeline?

 

this.shit16, this.shit2, this.shit19 are the in this.fire2 movieclip?

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
Explorer ,
Jun 18, 2024 Jun 18, 2024

thanks for the reply! No fire2 is actually button that controls 3 movie clips depending on the position of the current frame.

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 18, 2024 Jun 18, 2024

check your developer console for errors.  otherwise, that should work if fire2 is clicked when the timeline containing the code is between the 3rd and 25th frames.

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
Explorer ,
Jun 18, 2024 Jun 18, 2024

Thanks for the reply! I don't know what was wrong but it's working now.

BUT when using the if, if else and else statements, the movieClips were playing over each other in certain parts.

SO I went with 3 if statments instead and now they run smooth and separated? Don't know why.

So ->

this.fire2.addEventListener("click", fire.bind(this));
function fire()
{
//early shot
if (this.currentFrame > 1 && this.currentFrame < 14)
{
this.shit2.visible=true;
this.shit2.play();
}
//sweet shot
if (this.currentFrame > 13 && this.currentFrame < 18)
{
this.pepe.visible=false;
this.shit16.visible=true;
this.shit16.play();
}

//late shot
if (this.currentFrame > 17 && this.currentFrame < 29)
{
this.shit19.visible=true;
this.shit19.play();
}
}

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 18, 2024 Jun 18, 2024
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