Problem with Flying Menu
Sep 7, 2012 3:43 PM
Tags: none (add) #website #as3 #actionscript #boolean #sequencingI've been using a tutorial to teach myself some Flash and help build a portfolio website for some of my design. I seem to have everything figured out except this one problem that I have been mulling over for two weeks. The website has a flying menu that is in the middle of the page on the home page and then moves to the top right corner when on any of the other pages. This works fine for the first time you click on a page, but then as soon as you go home and try to leave again it gets stuck in the middle of the page. You can see the website at www.sierrahuckins.com if you don't understand what I mean.
I can't for the life of me figure out why it gets stuck. I don't think it's a problem with the coding because I already tried copying the coding straight from the working files that the tutorial provided in case I had mistyped something. But I'll include the scripts here so that you can see how it works.
Any help or ideas of what might be causing this would be highly appreciated.
/////////////////////////////////////////////////////////////////////
// Event Setup.
/////////////////////////////////////////////////////////////////////
logo_btn.addEventListener(MouseEvent.CLICK, navigationClicked);
home_btn.addEventListener(MouseEvent.CLICK, navigationClicked);
mainMenu_mc.profile_btn.addEventListener(MouseEvent.CLICK, navigationClicked);
mainMenu_mc.resume_btn.addEventListener(MouseEvent.CLICK, navigationClicked);
mainMenu_mc.contact_btn.addEventListener(MouseEvent.CLICK, navigationClicked);
mainMenu_mc.portfolio_btn.addEventListener(MouseEvent.CLICK, navigationClicked);
mainMenu_mc.photography_btn.addEventListener(MouseEvent.CLICK, navigationClicked);
/////////////////////////////////////////////////////////////////////
// Event Handlers.
/////////////////////////////////////////////////////////////////////
function navigationClicked(Event:MouseEvent):void
{
//We'll use this to store the Frame Label's name.
var frmLabel:String = '';
//Determine what Frame Label to use based on which
//button was clicked.
switch (Event.target)
{
case logo_btn :
frmLabel = "home_frm";
break;
case home_btn :
frmLabel = "home_frm";
break;
case mainMenu_mc.profile_btn :
frmLabel = "profile_frm";
break;
case mainMenu_mc.resume_btn :
frmLabel = "resume_frm";
break;
case mainMenu_mc.contact_btn :
frmLabel = "contact_frm";
break;
case mainMenu_mc.portfolio_btn :
frmLabel = "portfolio_frm";
break;
case mainMenu_mc.photography_btn :
frmLabel = "photography_frm";
break;
}
//Find the frame number based on our Frame Label.
var frmGoto:Number = this.getFrame(frmLabel);
//Don't do anything if we are already on the requested page.
if (currentFrame != frmGoto)
{
//Get and remember the Home page's frame number.
var frmHome:Number = this.getFrame("home_frm");
//If our requested page is the Home page, the flying menu
//needs to go home.
if(frmGoto == frmHome)
{
mainMenu_mc.goHome();
}
//Else, if we are on the Home page and are leaving, then
//leave home.
else if(currentFrame == frmHome)
{
mainMenu_mc.leaveHome();
}
//Go to the requested page.
gotoAndPlay(frmGoto);
}
}
/////////////////////////////////////////////////////////////////////
// Helper Functions.
/////////////////////////////////////////////////////////////////////
function getFrame(frameName:String):Number
{
var frame:Number = 1;
//Loop through all Frame Labels to find our requested frame.
for (var i = 0; i < currentLabels.length; i++)
{
if (currentLabels[i].name == frameName)
{
frame = currentLabels[i].frame;
break;
}
}
return frame;
}
function getFrameLabel(frame:Number):String
{
var frmLabel:String = '';
//Loop through all Frame Labels to find the requested Frame Label.
for (var i = 0; i < currentLabels.length; i++)
{
if (currentLabels[i].frame == frame)
{
frmLabel = currentLabels[i].name;
break;
}
}
return frmLabel;
}
function getSequencedFrame(forward:Boolean):String
{
//Used to remember the Frame Label of our page.
var frmSequence:String = '';
//If we're looking for the next page in sequence...
if(forward)
{
//If our current page is that last page...
if(currentFrame == this.getFrame("photography_frm"))
{
//...then, we need to go Home.
frmSequence = "home_frm";
}
else
{
//...else, we just need to go to the next frame.
frmSequence = this.getFrameLabel((currentFrame + 1));
}
}
//...else, we're looking for the previous page in sequence.
else
{
//If we're on the first page (remember, we skipped our Start page)...
if(currentFrame == this.getFrame("home_frm") ||
currentFrame == this.getFrame("start_frm"))
{
//...then, we need to go to the last page.
frmSequence = "photography_frm";
}
else
{
//...else, we just need to go to the the previous frame.
frmSequence = this.getFrameLabel((currentFrame - 1));
}
}
return frmSequence;
}



