Ok, so my first question here was so well answered I figure I'd try my luck at this little query.
Is there a better way to set up a flash project with lots of navigation than having to do this?:
bottomNav.contact_btn.addEventListener(MouseEvent.CLICK, changeContent);
bottomNav.portfolio_btn.addEventListener(MouseEvent.CLICK, changeContent);
bottomNav.news_btn.addEventListener(MouseEvent.CLICK, changeContent);
bottomNav.inspiration_btn.addEventListener(MouseEvent.CLICK, changeContent);
bottomNav.home_btn.addEventListener(MouseEvent.CLICK, changeContent);
secondaryNav.about_btn.addEventListener(MouseEvent.CLICK, changeContent);
secondaryNav.services_btn.addEventListener(MouseEvent.CLICK, changeContent);
secondaryNav.home_btn.addEventListener(MouseEvent.CLICK, changeContent);
secondaryNav.inspiration_btn.addEventListener(MouseEvent.CLICK, changeContent);
secondaryNav.inspiration_archive_btn.addEventListener(MouseEvent.CLICK, changeContent);
secondaryNav.portfolio_showcase_btn.addEventListener(MouseEvent.CLICK, changeContent);
secondaryNav.portfolio_archive_btn.addEventListener(MouseEvent.CLICK, changeContent);
and if not, there are always moments between animations where the last thing you want to happen is for someone to click a button and have another function fire off in the middle of your beautiful wipe between two scenes. You end up with (or at least I do) countless errors and a pissed off client.
What do you do to suspend all of those listeners without adding a function to the end of every other function to temporarily disable them?
Please, if someone has the magic practice, I'd love to hear it.
in regards to how I do it I've been writing something like this:
function suspendBtns():void
{
secondaryNav.inspiration_archive_btn.removeEventListener(MouseEvent.CLICK, changeContent);
secondaryNav.portfolio_showcase_btn.removeEventListener(MouseEvent.CLICK, changeContent);
secondaryNav.portfolio_archive_btn.removeEventListener(MouseEvent.CLICK, changeContent);
}
and would add suspendBtns(); to the end of every function that would transition between clips.
then obviously another function called enactBtns() or something like that.
I tried once just adding one event listener to the stage:
stage.addEventListner(MouseEvent.CLICK, doFunction);
and then the function would find the name of the btn like:
function doFunction(e:Event):void{
switch(e.target.name){
case"home_btn":
doThis();
break;
case"away_btn":
doThat();
break;
}
}
and so on. That didn't work so hot, it felt as though I had to click every button twice to get it to work.
And I still had to suspend the event listener in between actions.
Thanks in advance for your thoughts.