# Switching from Main Menu to Sub Menu problem in AS3

**URL:** <https://forum.kirupa.com/t/switching-from-main-menu-to-sub-menu-problem-in-as3/299630>\
**Category:** Uncategorized\
**Created:** [November 8, 2009, 4:10pm UTC](https://forum.kirupa.com/t/switching-from-main-menu-to-sub-menu-problem-in-as3/299630 "2009-11-08T16:10:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![riverswebb7](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@riverswebb7](https://forum.kirupa.com/u/riverswebb7)\
**Post date:** [November 8, 2009, 4:10pm UTC](https://forum.kirupa.com/t/switching-from-main-menu-to-sub-menu-problem-in-as3/299630/1 "2009-11-08T16:10:58Z")

</div>

[LEFT][FONT=Arial][SIZE=2][COLOR=#000000]This is script for my portfolio page menu. I have 3 main menu buttons and one sub menu button. Clicking on the sub menu (“graphicDes”) button should cause the 3 main menu buttons to transition out of sight WHILE causing hidden sub menu buttons to transition in to sight. [/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=#000000][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=#000000]So far the 3 main menu buttons load their pages. But the sub menu button does nothing when clicked. AND the animated menu change never happens no matter what I click. [/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=#000000][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=#000000]I’ve taken the script as far as I can think to take it. Can someone please take a look and help me?[/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=#000000][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=#000000]this is the main AS3:[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]stop();[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]mainPortMenu\_mc.stop();[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]subBtnMenu\_mc.stop();[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000][/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]subBtnMenu\_mc.graphicDes\_btn.addEventListener(MouseEvent.CLICK, navigationClicked);[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]subBtnMenu\_mc.freelance\_btn.addEventListener(MouseEvent.CLICK, navigationClicked)[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]subBtnMenu\_mc.trifolds\_btn.addEventListener(MouseEvent.CLICK, navigationClicked);[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]subBtnMenu\_mc.campaigns\_btn.addEventListener(MouseEvent.CLICK, navigationClicked);[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]subBtnMenu\_mc.backtomain\_btn.addEventListener(MouseEvent.CLICK, navigationClicked);[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000][/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]mainPortMenu\_mc.photoManip\_btn.addEventListener(MouseEvent.CLICK, navigationClicked);[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]mainPortMenu\_mc.fineArt\_btn.addEventListener(MouseEvent.CLICK, navigationClicked);[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]mainPortMenu\_mc.Anim\_btn.addEventListener(MouseEvent.CLICK, navigationClicked);[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000][/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]/////////////////////////////////////////////////////////////////////[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]// Sub Event Handlers.[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]/////////////////////////////////////////////////////////////////////[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]function navigationClicked(Event:MouseEvent):void [/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]{[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]//We’ll use this to store the Frame Label’s name.[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]var frmLabel:String = ‘’;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000][/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]//Determine what Frame Label to use based on which [/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]//button was clicked.[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]switch (Event.target)[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]{[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]case subBtnMenu\_mc.graphicDes\_btn :[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]frmLabel = “graphicDes\_frm”;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]break;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]case subBtnMenu\_mc.freelance\_btn :[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]frmLabel = “freelance\_frm”;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]break;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]case subBtnMenu\_mc.trifolds\_btn :[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]frmLabel = “trifolds\_frm”;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]break;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]case subBtnMenu\_mc.campaigns\_btn :[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]frmLabel = “campaigns\_frm”;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]break;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]case subBtnMenu\_mc.backtomain\_btn :[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]frmLabel = “main\_frm”;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]break;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000][/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]case mainPortMenu\_mc.photoManip\_btn :[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]frmLabel = “photoManip\_frm”;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]break;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]case mainPortMenu\_mc.fineArt\_btn :[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]frmLabel = “fineArt\_frm”;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]break;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]case mainPortMenu\_mc.Anim\_btn :[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]frmLabel = “anim\_frm”;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]break;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]}[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000][/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000][/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]///////////Find the frame number by Frame Label.[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]var frmGoto:Number = this.getFrame(frmLabel);[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000][/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]//Don’t do anything on requested page.[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]if (currentFrame != frmGoto) [/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]{[FONT=Arial][COLOR=#000000][/COLOR][/FONT][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=#000000][FONT=Verdana][COLOR=#990000]//Get Home page frame number.[/COLOR][/FONT][/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]var frmHome:Number = this.getFrame(“main\_frm”);[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000][/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]//If our requested page is the Home page, flying menu needs to go home[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]if(frmGoto == frmHome)[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]{[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]mainPortMenu\_mc.goHome();[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]}[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000][/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]if(frmGoto == frmHome)[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]{[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]subBtnMenu\_mc.goHome();[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]}[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]//Else, if on the Home page and are leaving, then leave home[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]else if(currentFrame == frmHome)[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]{[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]mainPortMenu\_mc.leaveHome();[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]}[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000][/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]else if(currentFrame == frmHome)[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]{[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]subBtnMenu\_mc.leaveHome();[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]}[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]//Go to the requested page.[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]gotoAndPlay(frmGoto);[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]}[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]}[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000][/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000][/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]///////////////////////Functions///////////////////////[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]function getFrame(frameName:String):Number [/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]{[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]var frame:Number = 1;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000][/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]//Loop through all Frame Labels to find requested frame.[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]for (var i = 0; i \< currentLabels.length; i++) [/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]{[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]if (currentLabels\*.name == frameName) [/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]{[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]frame = currentLabels\*.frame;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]break;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]}[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]}[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000][/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]return frame;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]}[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000][/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]function getFrameLabel(frame:Number):String [/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]{[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]var frmLabel:String = ‘’;[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000][/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]}[FONT=Arial][COLOR=#000000][/COLOR][/FONT][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=#000000][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=#000000][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=#000000]This bit of code appears in the timeline for the animated main and sub menu buttons themselves:[/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=#000000][/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]function goHome():void[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]{[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]gotoAndPlay(20);[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]}[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000][/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]function leaveHome():void[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]{[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]gotoAndPlay(1);[/COLOR][/SIZE][/FONT]  
[FONT=Verdana][SIZE=2][COLOR=#990000]}[FONT=Arial][COLOR=#000000][/COLOR][/FONT][/COLOR][/SIZE][/FONT][/LEFT]
