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

In Animate HTML5 canvas on named last frame of movie clip gotoAndStop on named main timeline frame

Participant ,
Jan 20, 2024 Jan 20, 2024

Copy link to clipboard

Copied

I have a movie clip on stage on top of a graphic. When the main timeline movie gets to this frame it stops and plays the nested movie clip. I want to code from the main timeline actionscript layer an event listener that detects when the last named frame of the nested clip is played and goto and stop on a named frame of the main timeline.

 

So, for example.

 

On frame 30 which is named "question_1" is a button click event listener that goes to the next frame "question1_answer1":

 

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

function fl_MouseClickHandler()
{
      this.gotoAndStop("question1_answer1");

}

 

on "question1_answer1" there is a "this.stop();" and a movie clip on the stage named "qchicken" that runs an animation. On the last frame of "qchicken" I have named the frame "chicken_down" at which point I want to go back to "question_1" on the main timeline. So how do I write an event listener that does this:

 

this.qchicken.EVENT LISTENER THAT DETECTS WHEN "chicken_down" IS REACHED.parent.gotoAnd Stop("question_1");

 

And finally, how and where do I put the remove event listener code once the goto is executed (and similarly once a button is pressed on other events)? I've seen more than one variation of writing remove event listener in posts and examples of it being placed before and after the event code. Which is correct?

 

 

 

TOPICS
ActionScript , Code , Timeline

Views

483

Translate

Translate

Report

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

Participant , Feb 08, 2024 Feb 08, 2024

Thanks. So, with the gotoAndStop line the complete working

var _this = this;
var chicken_downFF = chicken_downF.bind(this);
createjs.Ticker.addEventListener("tick", chicken_downFF);

function chicken_downF() {

	if (_this.qchicken.currentLabel == "chicken_down") {
		createjs.Ticker.removeEventListener("tick", chicken_downFF);
		_this.gotoAndStop("question_1");
	}
}

code looks like this:

 

Votes

Translate

Translate
Participant ,
Feb 08, 2024 Feb 08, 2024

Copy link to clipboard

Copied

Oops, broke up my text line - like this:

 

var _this = this;
var chicken_downFF = chicken_downF.bind(this);
createjs.Ticker.addEventListener("tick", chicken_downFF);

function chicken_downF() {

	if (_this.qchicken.currentLabel == "chicken_down") {
		createjs.Ticker.removeEventListener("tick", chicken_downFF);
		_this.gotoAndStop("question_1");
	}
}

Votes

Translate

Translate

Report

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 ,
Feb 08, 2024 Feb 08, 2024

Copy link to clipboard

Copied

LATEST

you're welcome.

Votes

Translate

Translate

Report

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