Copy link to clipboard
Copied
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:
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!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
No, you have to use a listener.
To remove you just do like: right_btn.removeEventListener(MouseEvent.CLICK, clickRight1);
Copy link to clipboard
Copied
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"); } |
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Find more inspiration, events, and resources on the new Adobe Community
Explore Now