Skip to main content
Inspiring
February 26, 2019
Answered

Reset Movieclip

  • February 26, 2019
  • 6 replies
  • 2959 views

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

    This topic has been closed for replies.
    Correct answer kdmemory

    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

    6 replies

    cmpcpercAuthor
    Inspiring
    March 13, 2019

    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....

    cmpcpercAuthor
    Inspiring
    March 6, 2019

    Okay seems to be working. Thanks alot KD

    kdmemory
    Inspiring
    March 6, 2019

    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

    cmpcpercAuthor
    Inspiring
    March 6, 2019

    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...

    cmpcpercAuthor
    Inspiring
    March 4, 2019

    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.

    kdmemory
    kdmemoryCorrect answer
    Inspiring
    February 26, 2019

    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

    cmpcpercAuthor
    Inspiring
    February 28, 2019

    Klaus

    Sorry about the late response, I will try your method, thanks a lot.

    Abambo
    Community Expert
    Community Expert
    February 26, 2019

    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.

    ABAMBO | Hard- and Software Engineer | Photographer
    cmpcpercAuthor
    Inspiring
    February 26, 2019

    Hi sorry, I did put it in the tag on the post so thought that was enough.

    Abambo
    Community Expert
    Community Expert
    February 26, 2019

    Sorry, but the tags are empty...? 

    ABAMBO | Hard- and Software Engineer | Photographer