7 Replies Latest reply: Apr 19, 2010 3:56 PM by kglad RSS

    "Refreshing" frame?

    Shed Simas Community Member

      Hi,

       

      Is there a way to get a movie clip to replay the current frame from the beginning?

       

      I have a movie clip that disables itself when clicked, and I want it to be reenabled via another button. Right now I'm using removeEventListener to disable the clip, and trying to addEventListener with the second button, but it is not working. Is there a way to get this to work, or to get the function to "refresh" the current frame so that the buttons are enabled (as if nothing happened)?

       

      Thanks,

       

      Shed

        • 1. Re: "Refreshing" frame?
          kglad CommunityMVP

          there's no problem adding an event listener.  why are you having trouble?


          • 2. Re: "Refreshing" frame?
            Shed Simas Community Member

            I don't know. But, this is the code I was using. There are multuple buttons for the same functions so here's a simplified version with only one:

             

            stop();
            
            deerphoto.addEventListener(MouseEvent.CLICK, openThis);
            deerphoto.buttonMode = true;
            
            function openThis(myEvent:MouseEvent):void {
                myEvent.currentTarget.gotoAndPlay(currentFrame+1);
                myEvent.currentTarget.removeEventListener(MouseEvent.CLICK, openThis);
                myEvent.currentTarget.buttonMode = false;
                deerphoto.closeCard.addEventListener(MouseEvent.CLICK, closeThis);
            }
            
            function closeThis(myEvent:MouseEvent):void {
                gotoAndPlay(3);
                myEvent.currentTarget.addEventListener(MouseEvent.CLICK, openThis);
                myEvent.currentTarget.buttonMode = true;
            }
            

             

             

            The thing is right now I'm having even more trouble because I tweened my buttons and now  they are within a "Tween" symbol and I can't access them. I don't want to convert it to frame-by-frame, but I can't think of any other solutions...

            • 3. Re: "Refreshing" frame?
              kglad CommunityMVP

              that's not going to work.  you're trying to add a mouse listener to whatever just called closeThis() and that object presumably already has a listener.

               

              try:

               


              stop();

              deerphoto.addEventListener(MouseEvent.CLICK, openThis);
              deerphoto.buttonMode = true;

              function openThis(myEvent:MouseEvent):void {
                  myEvent.currentTarget.gotoAndPlay(currentFrame+1);
                  myEvent.currentTarget.removeEventListener(MouseEvent.CLICK, openThis);
                  myEvent.currentTarget.buttonMode = false;
                  deerphoto.closeCard.addEventListener(MouseEvent.CLICK, closeThis);
              }

              function closeThis(myEvent:MouseEvent):void {
                  MovieClip(myEvent.currentTarget.parent).addEventListener(MouseEvent.CLICK, openThis);
              myEvent.currentTarget.removeEventListener(MouseEvent.CLICK,closeThis);  // not sure you want this
              gotoAndPlay(3);
              }

               

               

              • 4. Re: "Refreshing" frame?
                Shed Simas Community Member

                Hmm, I'm still having the same problem. Clicking "deerphoto" opens it up and disables it, but clicking "deerphoto.closeCard" only closes it, and does not re-enable it.

                • 5. Re: "Refreshing" frame?
                  kglad CommunityMVP

                  remove that gotoAndPlay() to see if that's causing a problem.

                  • 6. Re: "Refreshing" frame?
                    Shed Simas Community Member

                    I did, but still no change...

                    • 7. Re: "Refreshing" frame?
                      kglad CommunityMVP

                      what the following trace reveal:

                       


                       


                      stop();

                      deerphoto.addEventListener(MouseEvent.CLICK, openThis);
                      deerphoto.buttonMode = true;

                      function openThis(myEvent:MouseEvent):void {
                          myEvent.currentTarget.gotoAndPlay(currentFrame+1);
                          myEvent.currentTarget.removeEventListener(MouseEvent.CLICK, openThis);
                          myEvent.currentTarget.buttonMode = false;
                          deerphoto.closeCard.addEventListener(MouseEvent.CLICK, closeThis);
                      }

                      function closeThis(myEvent:MouseEvent):void {
                          MovieClip(myEvent.currentTarget.parent).addEventListener(MouseEvent.CLICK, openThis);
                      trace(
                      MovieClip(myEvent.currentTarget.parent).name)
                      myEvent.currentTarget.removeEventListener(MouseEvent.CLICK,closeThis);  // not sure you want this
                      gotoAndPlay(3);
                      }

                       

                       

                      The thing is right now I'm having even more trouble because I tweened my buttons and now  they are within a "Tween" symbol and I can't access them. I don't want to convert it to frame-by-frame, but I can't think of any other solutions...