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?
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:
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");
}
}
Copy link to clipboard
Copied
you're welcome.