Buttons stop working after a few frames
- April 15, 2023
- 1 reply
- 788 views
Hello, Im trying to get some buttons to work in a few frames after frame 164, the buttons on frame 186 and 200 don't work no matter what I try. I can't really find any errors in the console either. My Question is what am I doing wrong and how can I fix these buttons so that I can make more and finish the rest of it.
Before I was using the code snippets but I also tried the add using wizard and none seem to work.
Frame 1
/* Stop at This Frame
The timeline will stop/pause at the frame where you insert this code.
Can also be used to stop/pause the timeline of movieclips.
*/
this.stop();
/* Click to Go to Frame and Play
Clicking on the specified symbol instance moves the playhead to the specified frame in the timeline and continues playback from that frame.
Can be used on the main timeline or on movie clip timelines.
Instructions:
1. Replace the number 5 in the code below with the frame number you would like the playhead to move to when the symbol instance is clicked.
2.Frame numbers in EaselJS start at 0 instead of 1
*/
this.startgame.addEventListener("click", fl_ClickToGoToAndPlayFromFrame_4.bind(this));
function fl_ClickToGoToAndPlayFromFrame_4() {
this.gotoAndPlay(4);
}
var root = this; // here we store a reference to the main timeline
var muteButton = root.muteButton; // here we store a reference to the mute/unmute button
root.toggleMute = function (e)
{
createjs.Sound.muted = !createjs.Sound.muted; // here we invert the sound state (muted/unmuted)
if (createjs.Sound.muted)
root.toggleButton(e.currentTarget, {
out: 2,
over: 2,
down: 2
}); // set the same frame number to the main button states (out, over, and down)
else
root.toggleButton(e.currentTarget, {
out: 0,
over: 1,
down: 2
}); // reset the button frames
};
// convenience/utility method to toggle default button symbols instances on and off
root.toggleButton = function (button, frames)
{
var listeners = button._listeners;
if (!listeners)
return;
for (var key in listeners) {
var listener = listeners[key][0];
if (typeof (listener.outLabel) !== 'undefined')
listener.outLabel = frames.out;
if (typeof (listener.overLabel) !== 'undefined')
listener.overLabel = frames.over;
if (typeof (listener.downLabel) !== 'undefined')
listener.downLabel = frames.down;
}
button.gotoAndStop(frames.out);
};
muteButton.on("mousedown", root.toggleMute); // mouse down listener added to the mute/unmute button
Frame 164
/* Stop at This Frame
The timeline will stop/pause at the frame where you insert this code.
Can also be used to stop/pause the timeline of movieclips.
*/
this.stop();
/* Click to Go to Frame and Stop
Clicking on the specified symbol instance moves the playhead to the specified frame in the timeline and stops the movie.
Can be used on the main timeline or on movie clip timelines.
Instructions:
1. Replace the number 5 in the code below with the frame number you would like the playhead to move to when the symbol instance is clicked.
2.Frame numbers in EaselJS start at 0 instead of 1
*/
this.LeftArrow.addEventListener("click", fl_ClickToGoToAndStopAtFrame_186.bind(this));
function fl_ClickToGoToAndStopAtFrame_186() {
this.gotoAndStop(186);
}
/* Click to Go to Frame and Stop
Clicking on the specified symbol instance moves the playhead to the specified frame in the timeline and stops the movie.
Can be used on the main timeline or on movie clip timelines.
Instructions:
1. Replace the number 5 in the code below with the frame number you would like the playhead to move to when the symbol instance is clicked.
2.Frame numbers in EaselJS start at 0 instead of 1
*/
this.RightArrow.addEventListener("click", fl_ClickToGoToAndStopAtFrame_200.bind(this));
function fl_ClickToGoToAndStopAtFrame_200() {
this.gotoAndStop(200);
}
Frame 186
var _this = this;
/*
Clicking on the specified symbol instance executes a function.
*/
_this.YL.on('click', function(){
/*
Moves the playhead to the specified frame number in the timeline and stops the movie.
Can be used on the main timeline or on movie clip timelines.
*/
_this.gotoAndStop(205);
});
var _this = this;
/*
Clicking on the specified symbol instance executes a function.
*/
_this.YR.on('click', function(){
/*
Moves the playhead to the specified frame number in the timeline and stops the movie.
Can be used on the main timeline or on movie clip timelines.
*/
_this.gotoAndStop(208);
});
Frame 200
var _this = this;
/*
Clicking on the specified symbol instance executes a function.
*/
_this.door.on('click', function(){
/*
Moves the playhead to the specified frame number in the timeline and stops the movie.
Can be used on the main timeline or on movie clip timelines.
*/
_this.gotoAndStop(211);
});
This was the console warnings -

