Copy link to clipboard
Copied
Hi
I was wondering, I am doing navigation via html5 canvas javascript and am using label names to go to areas. I have nested movieclips within these labels too. Say I this.gotoandstop(); then have a back button to take me back to the main timeline, and then go to that gotoandstop() a second time, the nested movieclip is playing from when I pressed the back button and not from the start as you'd expect from a gotoandstop(). Any ideas how to reset a movieclip to first frame when pressing back button? Also, I have made every label 2 frames long because if they are single frames, the movie clip doesnt play at all.
Thanks
Hi Charlie
First of all your explanation of the problem is a bit difficult to get. Sorry. Can you share a FLA where this problem occurs?
Anyway if you use a button with an assigned script like this.gotoAndStop(..); and both are on the main timeline in a frame with a label then this code is working only insofar as the playhead for the main timeline jumps to whatever you've put into the (..) of that command. A nested movieclip in the same frame with a label would not automatically react with a reset
...Copy link to clipboard
Copied
I'm assuming that you are using Animate, so I moved your thread from Adobe Creative Cloud to Adobe Animate CC .
If you are not using Animate state the Adobe product you're using so that a moderator can move again.
Copy link to clipboard
Copied
Hi sorry, I did put it in the tag on the post so thought that was enough.
Copy link to clipboard
Copied
Sorry, but the tags are empty...?
Copy link to clipboard
Copied
I probably didnt press enter after enetring the tag name then, sorry about that and thanks for moving it to the correct place!
Copy link to clipboard
Copied
I simply guessed, but I hope for you that an Animate specialist will show up soon! Have a nice day.
Copy link to clipboard
Copied
Hi Charlie
First of all your explanation of the problem is a bit difficult to get. Sorry. Can you share a FLA where this problem occurs?
Anyway if you use a button with an assigned script like this.gotoAndStop(..); and both are on the main timeline in a frame with a label then this code is working only insofar as the playhead for the main timeline jumps to whatever you've put into the (..) of that command. A nested movieclip in the same frame with a label would not automatically react with a reset.
If you would provide an instance name (i.e. "nestedmc") to that nested movieclip and your code assigned to your back button (suppose this one is named "backbutton") would go like this:
var _this = this;
_this.backbutton.on("click", function () {
_this.nestedmc.gotoAndStop(0); // this would be a reset to the first frame
_this.gotoAndStop(0); // or label if you have one
});
This might work. I say "might", because it's hard to understand precisely the given scenario from your description. You would have to share your file with us.
Also it might be a problem, where you have to uncheck Use Advanced Layers under Modify -> Document ...
Klaus
Copy link to clipboard
Copied
Klaus
Sorry about the late response, I will try your method, thanks a lot.
Copy link to clipboard
Copied
KDmemory, or anyone, please can you have a quick look at the attached file.
I cant seem to still get it to work. if you click 'by theme', then 'food poverty', this is the problem, as whenever I click the back button, then go back to the 'food poverty' it does strange things such as play without stopping, or remember where it was before I pressed 'back'. I have made all labels two frames long because if they are one frame, the gotoandstop("labelname") doesnt play the movieclip behind the label if its one frame long.
This is all important because I am going to be nesting within movieclips a lot to keep my project organised.
Please forgive my javascript skills.
Thanks a lot for your help.
Copy link to clipboard
Copied
Hi Charlie
I downloaded your file and see somewhat the problem. I takes a little time to work something out. Please be a bit patient.
Klaus
Copy link to clipboard
Copied
Hi Charlie
It's late now, hence I do not explain every aspect of my intervention. Maybe tomorrow if you ask me kindly. It's of course important to learn, though sometimes explanations are soo tiring. Anyway:
(I extended your frames a bit, so that one can read out the labels)
Put there in the actions layer where the blue marker is the following script:
var here = this;
stage.on("drawstart", function () {
here.mcFP.gotoAndStop(0);
}, here, true);
this.mcMK.dtTitle.text = "FOOD POVERTY";
this.btnBack.addEventListener("click", BackClick.bind(this));
function BackClick() {
this.gotoAndStop("lblThemes");
}
This sorts out your problem halfway. Still if you click on of the left hand buttons and go within mcFP to another frame than 0 then a brief visual glitch still occurs. I'll think about that, but not now . Ask me again, and also when you run into related trouble.
Good night
Klaus
Copy link to clipboard
Copied
Klaus
I wasnt expecting your response so late at night, thanks a lot but you didnt need to go out of your way so soon! Thanks so much, ill try it tomorrow and will let you know. I assume this is an issue with adobe animate then rather than poor structure/code on my part.
Thanks again and ill be in touch once I get to resolving the glitch.
Charlie
Copy link to clipboard
Copied
Hi Charlie
It was no problem yesterday, only in the very end a bit tired. Had a mad series of multitasking work.
Now, you know I use to build this kind of multimedia presentation in just one frame and use variables and properties like visible and/or alpha to control the appearance of wanted and disapperance of unwanted movieclips. Or I would use coded Tweens to make movieclips fly in or out the stage according to the situation. This way everything is always available to be coded upon. I use movieclips with multiple frames only in real animations, not to pop in or out of screens. Anyway, I know that can be a little confusing.
I revised the script from yesterday so that the little glitch doesn't happen anymore:
var here = this;
here.resetNestedMC = function () {
here.mcFP.gotoAndStop(0);
};
stage.on("drawstart", function () {
here.resetNestedMC();
}, here, true);
here.mcMK.dtTitle.text = "FOOD POVERTY";
here.btnHome.addEventListener("click", HomeClick.bind(here));
function HomeClick() {
here.resetNestedMC();
here.gotoAndStop("lblHome");
}
here.btnBack.addEventListener("click", BackClick.bind(here));
function BackClick() {
here.resetNestedMC();
here.gotoAndStop("lblThemes");
}
I included the btnHome.addEventListener too. You can use this script for all those screens with nested movieclips like "let's get moving", "social enterprise" etc. Only the particular instance name of the nested mc needs to be swapped in line 04 and of course the text in line 11.
So
Klaus
Copy link to clipboard
Copied
Thanks so much, im going to try this now. With regards to maybe coding / layout and structure, your advice is appreciated. Ive been using Animate for 3 months r so, so know I am going to be doing things not the best way. The reason I didnt do everything on one frame and then show/hide etc is because I thought by doing that, it will all be in memory and would crash the application. I will bear it in mind for my next project though.
Of course another alternative is to have absolutely everything on the main timeline but I did the nested to try to be organised but I understand its made it more complicated! Thanks again KD.
Copy link to clipboard
Copied
KD thanks. I think I know the problem but cant solve it. Its to do with the hierarchy and/or the fact that the gotoandstop could be on frame 2 of the movieclip when I press 'back'. Then when I go back to the movie clip, it is playing from frame 2 therefore bypassing this.stop() at frame 1. But ti shouldnt be doing this at all in my eyes because I am telling the movie clip to stop at frame 1.
I have somehow caused what seems an infinite loop or something because to me pressing back should reset things automatically, but it isnt doing that. Im being patient but this has baffled me for a long time now which is why im seeking support, thanks KD.
Copy link to clipboard
Copied
Hmmm, when I press back it goes to the home page, im trying to work it out as to why as the code seems to be correct. Also when then going back into 'Food Poverty' the glitch still happens, ill try restarting animate...
Copy link to clipboard
Copied
Okay seems to be working. Thanks alot KD
Copy link to clipboard
Copied
Pleasure, Charlie.
So, Flintshire in Wales? I got curious and looked it up on Google Maps and Wikipedia .
What you were saying that pressing the BackButton linked to Home at first, it's really funny your file. I had your file open this morning, not to work on it, I just needed something open with multiple frames. And out of fiddling around I published your movie and then at first BackButton brought me too to the Homepage. I swear yesterday it didn't happen that way. So I published again and now it's fine. But something is not right.
Because of my looking up Flintshire I went to More Info and clicked the link www.foodpovertyconference.co.uk . It opened my email client and made a message ready to Jen.Griffiths@flintshire.gov.uk. Which is the next Link. The instance name of the first link is fpConference. And on that frame is a code going like this:
this.fpConference.addEventListener("click", fl_ClickToGoToWebPage);
function fl_ClickToGoToWebPage() {
window.open("http://www.flintshire.gov.uk", "_blank");
}
this.mcFPemail.addEventListener("click", fl_ClickToGoToWebPage);
function fl_ClickToGoToWebPage() {
window.open("mailto:jen.griffiths@flintshire.go.uk", "_blank");
}
So why is it jumping to the next link or item? Somewhat similar to the Back and Home phenomenon. I can't put my finger on it, but something is a bit shaky with your navigational scripts.
BTW: the weblink should be a button with a hitarea.
Klaus
Copy link to clipboard
Copied
Hi, yes Flintshire in Wales .
Yes there was some strange goings on but it seems to be behaving now! Im trying to restructure it so I have everything on the main timeline, with just movieclip animations being nested.
Its all experience....
Find more inspiration, events, and resources on the new Adobe Community
Explore Now