6 Replies Latest reply: Mar 19, 2010 1:07 PM by TorQue[MoD] RSS

    Weird timeline loop in entire flash site?

    TorQue[MoD] Community Member

      Ok, I'm really starting to loose my faith in using flash as a useful website design program! I've come across this really weird glitch that makes absolutely no sense, and I thought it was limited to one of the buttons in my site, but now apparently its affecting the entire website which doesn't make a lick of sense!

       

      This is the website:

       

      http://www.equinisity.com/

       

      What's happening is you use the right and left arrows to navigate the site, but for some odd reason, if you move forward several pages, then move back several pages, then try to move forward again, it gets stuck in the transition between those two pages permanently. Test it out to see what I mean.

       

      The weirdest thing is that it seems to work fine if you only go back one page and then forward again, but if you go back several pages and then try to move forward, it gets stuck. Same thing happens in the other direction.

       

      The weirdest part is I've been using code taken from a flash tutorial on lynda.com so it should work!

       

      Here's an example of my code:

       

      Sample Code:
      //This is the Intro Page
      stop();
      //handle button events
      left_btn.addEventListener(MouseEvent.CLICK, clickLeft1);
      right_btn.addEventListener(MouseEvent.CLICK, clickRight1);
      function clickLeft1(evtObj:MouseEvent){
      gotoAndPlay ("intro_start");
      }
      function clickRight1(evtObj:MouseEvent){
      gotoAndPlay ("trailer_start");
      }

       

      I'm using the following code on every page though I simply append then next logical number to the EventListener (IE clickLeft2 for page 2 etc.), and I've simply created a "slide in" and "slide out" for each page in the timeline so I don't see how this would be a problem.

       

      Please, if you can help me make sense of this, I will be very greatful!

        • 1. Re: Weird timeline loop in entire flash site?
          dmeN Community Member

          It's not Flash, I can guarantee that. It's your code... you have to remove listeners from objects. If you add a second listener, calling a different function - then both listeners will execute... likely it's that you just need to remove prior listeners, before adding new ones. Add some trace statements in your listener functions to show the problem.

          • 2. Re: Weird timeline loop in entire flash site?
            TorQue[MoD] Community Member
            Yeah, I figured it wasn't flash, its just very frustrating with the little understanding I do have of the program.
            So the problem is in using the same button to call multiple listeners at different points in the timeline without first removing the old one?
            How does one go about removing a listener? I'm completely new to AS3 and flash code in general.
            Is there a better way to tell a button to move to a new place in the timeline without creating a listener? This is the only way I know how to get a button to function.
            Thank you.
            • 3. Re: Weird timeline loop in entire flash site?
              dmeN Community Member

              No, you have to use a listener.

               

              To remove you just do like: right_btn.removeEventListener(MouseEvent.CLICK, clickRight1);

              • 4. Re: Weird timeline loop in entire flash site?
                TorQue[MoD] Community Member
                So then my new code would be as follows? :
                Code
                //This is the Trailer Page
                stop();
                //remove previous listeners
                right_btn.removeEventListener(MouseEvent.CLICK, clickRight1);
                left_btn.removeEventListener(MouseEvent.CLICK, clickLeft1);
                //handle button events
                left_btn.addEventListener(MouseEvent.CLICK, clickLeft2);
                right_btn.addEventListener(MouseEvent.CLICK, clickRight2);
                function clickLeft2(evtObj:MouseEvent){
                import flash.media.SoundMixer;
                SoundMixer.stopAll();
                gotoAndPlay ("trailer_leave");
                }
                function clickRight2(evtObj:MouseEvent){
                SoundMixer.stopAll();
                gotoAndPlay ("workshop_start");
                }
                If this works you'll be my hero!
                • 5. Re: Weird timeline loop in entire flash site?
                  dmeN Community Member

                  Well, from what you described I think that looks good. And like I mentioned, you can use trace statements in your listener functions to see that they're executing - ie you'd see two traces go off if you haven't removed... FWIW, sometimes two listeners on the same button can be really helpful.

                  • 6. Re: Weird timeline loop in entire flash site?
                    TorQue[MoD] Community Member
                    Oh yeah, I WAS using traces before, and I DID see two go off at the same time, I just didn't know what it meant!
                    Thank you so much dmennenoh! The problems are now completely fixed! I've been struggling with this for weeks and didn't have a clue what was going on! Sure wish that lynda.com tutorial actually mentioned needing to remove listen events if you add them to the same button, but I guess his website didn't use that format, so why would he think to?
                    You are now my Hero and have renewed my faith in Flash!
                    Thank you thank you thank you!