Copy link to clipboard
Copied
Hi All,
I have been looking for the solution to this and have tried multiple things but to no avail. I am super new to Adobe Animate so it might be something I'm completely overlooking.
My project is set up like this:
My code for reference:
var root = this;
root.stop();
var who_value = 0;
window.edit_value = 0;
console.log(edit_value);
/* BACKGROUND MENU */
root.MENU_BUTTON8.addEventListener("click", fl_ClickToGoToAndStopAtFrame_2.bind(root));
function fl_ClickToGoToAndStopAtFrame_2() {
root.gotoAndStop("BG_COLOR_MENU_BUTTON");
}
root.MAN_BUTTON.addEventListener("click", fl_ClickToGoToAndStopAtFrame_WHO.bind(root, 1));
root.WOMAN_BUTTON.addEventListener("click", fl_ClickToGoToAndStopAtFrame_WHO.bind(root, 2));
root.MANWOMAN_BUTTON.addEventListener("click", fl_ClickToGoToAndStopAtFrame_WHO.bind(root, 0));
root.MANMAN_BUTTON.addEventListener("click", fl_ClickToGoToAndStopAtFrame_WHO.bind(root, 3));
root.WOMANWOMAN_BUTTON.addEventListener("click", fl_ClickToGoToAndStopAtFrame_WHO.bind(root, 4));
function fl_ClickToGoToAndStopAtFrame_WHO(who_number) {
who_value = who_number;
root.WHOBUTTONOVERLAY_MC.gotoAndStop(who_value);
if (who_value == 1 || who_value == 3) {
window.edit_value = 2;
console.log(window.edit_value);
root.MAN1_MC.EDITBUTTON_MAN1and2_MC.gotoAndStop(1);
}
}
Despite this, what I want doesn't work and I get the error "Cannot read property gotoAndStop of undefined" in the Console.
Is there something I'm missing here? Is this a load error (which I have read on many answers and have tried to fix)? Am I calling the children incorrectly? Any help is appreciated!
-Melanie
just above your problematic code put:
console.log("calling MAN1_MC.EDITBUTTON_MAN1and2_MC");
and on the 2nd frame of MAN1_MC.EDITBUTTON_MAN1and2_MC put:
console.log(this.name);
console.log(this.parent.name);
test>open your console and check the log statements. if that doesn't make clear your error, post the three log statements in another message.
Copy link to clipboard
Copied
just above your problematic code put:
console.log("calling MAN1_MC.EDITBUTTON_MAN1and2_MC");
and on the 2nd frame of MAN1_MC.EDITBUTTON_MAN1and2_MC put:
console.log(this.name);
console.log(this.parent.name);
test>open your console and check the log statements. if that doesn't make clear your error, post the three log statements in another message.
Copy link to clipboard
Copied
Thank you for the reply! I have to admit - I feel somewhat honored getting a reply from you. I've definitely been saved before by your answers on other threads.
Your debugging advice was very helpful. When I did it, I ended up getting null in the console log for all the names. That led me to find this other thread (https://community.adobe.com/t5/animate/movieclip-instance-names-not-available-from-name-property-in-...) where I learned that instance names aren't available from just the .name property in Animate CC 2017 (which is what I have). I added the code from ClayUUID in the first frame of my main timeline and through more of the same type of debugging I realized that first, I had a typo in the name of one of my instances (woops) and second, I hadn't even named the other instance (double woops).
All this explanation is just for any future person who might find this thread helpful. Thank you again!
Copy link to clipboard
Copied
you're welcome.