Skip to main content
August 10, 2011
Question

Linked Animations Between Pages

  • August 10, 2011
  • 1 reply
  • 310 views

Hello Flash Experts,


I'm new to Flash and AS 3, and I'm hoping you can shed some light on my issue.


I have a website that I have designed with 5 layers - actions, background, menu, pageintro, pageoutro. The pageintro and pageoutro layers have 24 frames for each page (120 total) and each contain tweens, pageintro flys in from the right, and pageoutro flys out to the left. Each intro page is labeled as page1, page2, etc... and for outros page1out, page2out, etc..

My issue is that the animation will only play the intro and page outro simultaneously for the current page (the one that is clicked) - i.e. if I click about, the page2out flys out while page2 flys in. I would like the current page to fly out, and the next page to fly in.


Here is the code:

gotoAndStop("page1"); /*prevents the animation from going through entire timeline*/ var currentPage:int = 0; /*Keeps track of current page*/ var nextPage:int; /*Handles  PageOut*/ function pagingOut(fadePage:int) {     switch (fadePage) {         case 0:             gotoAndPlay("page1out");             break;         case 1:             gotoAndPlay("page2out");             break;         case 2:             gotoAndPlay("page3out");             break;         case 3:             gotoAndPlay("page4out");             break;         case 4:             gotoAndPlay("page5out");             break;         default:             break;     } } /*Handles  PageIn*/ function pagingIn(fadePage:int) {     switch (fadePage) {         case 0:             gotoAndPlay("page1");             break;         case 1:             gotoAndPlay("page2");             break;         case 2:             gotoAndPlay("page3");             break;         case 3:             gotoAndPlay("page4");             break;         case 4:             gotoAndPlay("page5");             break;         default:             break;     }     currentPage=fadePage; } /*Deals with the Clicks of Main Menu*/ function home_mc_clicked(e:MouseEvent) :void{         pagingOut(currentPage);     currentPage=0; } function aboutus_mc_clicked(e:MouseEvent) :void{     pagingOut(currentPage);     currentPage=1} function services_mc_clicked(e:MouseEvent) :void{     pagingOut(currentPage);     currentPage=2} function employment_mc_clicked(e:MouseEvent) :void{     pagingOut(currentPage);     currentPage=3} function contactus_mc_clicked(e:MouseEvent) :void{     pagingOut(currentPage);     currentPage=4} function mainMenuClicked(event:MouseEvent) {        var nextPageName:String= event.target.name;     if (nextPageName=="home_mc")         nextPage=0;     else if (nextPageName=="aboutus_mc")         nextPage=1;     else if (nextPageName=="services_mc")         nextPage=2;     else if (nextPageName=="employment_mc")         nextPage=3;     else if (nextPageName=="contactus_mc")         nextPage=4;             trace (currentPage);     trace(nextPage);     pagingOut(currentPage);     pagingIn(nextPage);     //stop();         } /*LISTENS FOR MOUSING OVER AND OUT OF THE MAIN MENU*/ for (var i:uint = 0; i < buttonsArr.length; i++) {     buttonsArr[i].addEventListener(MouseEvent.CLICK, mainMenuClicked);     buttonsArr[i].addEventListener(MouseEvent.ROLL_OVER, moveFollow);     buttonsArr[i].addEventListener(MouseEvent.ROLL_OUT, moveLeave);

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
August 11, 2011

Your description of the problem is probably clear to you as far as what pages are involved, but not so much for anyone reading what you wrote.  In any case, if you are trying to call the pagingIn and pagingOut functions at the same time, only one of them is going to win because you can only be in one place in the timeline at a time.  To do what you probably want using a timeline-based approach you would need to first process the pagingOut and at the completion of that have a command telling it where to go to process the next page coming in.  Pages could not be animating simultaneously unless they were consecutive/overlapping in the timeline.