A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Creating a simple menu

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    1

    Creating a simple menu

    I've searched for tutorials and help on this for days, but I haven't found a single tutorial for creating a menu with multiple pages in Flash/AS.
    I'm trying to create a menu with multiple pages. I've already laid out every single page on a separate frame, for example main menu on frame 1, options on frame 2, characters on frame 3, about on frame 4, character1 on frame 5, character2 on frame 6, etc. On each menu page there are links (movieclip instances), when clicked will go to another frame. However some links exist on multiple pages, basically duplicated instances, since they all head to the same page when clicked. For example, the "backToMain" link will lead back to frame 1, however it exists on let's say frame 2, 3, 5, 7, 9, 14, etc.
    This is what I have so far:

    Actionscript Code:
    var linksArray:Array =
                                [
                                //Main menu
                                menuRightSide.newStoryLink,
                                menuRightSide.continueStoryLink,
                                menuRightSide.selectChapterLink,
                                menuRightSide.optionsLink,
                                menuRightSide.charactersLink,
                                menuRightSide.aboutLink,

                                //chapters menu
                                menuRightSide.chapter1Link,
                                menuRightSide.chapter2Link,
                                menuRightSide.chapter3Link,
                                    menuRightSide.chapter4Link,
                                menuRightSide.chapter5Link,
                               
                                //characters main menu
                                menuRightSide.char1Link,
                                menuRightSide.char2Link,
                                menuRightSide.char3Link,
                                menuRightSide.char4Link,
                                menuRightSide.char5Link,
                                menuRightSide.char6Link,
                               
                                //options main menu
                                menuRightSide.languageLink,
                                menuRightSide.costumeLink,
                               
                                ...
                                                            ...
                               
                                //function links exist on multiple pages
                                menuRightSide.backToMainLink,
                                menuRightSide.backToCharLink,
                                menuRightSide.backToOptionsLink,
                                menuRightSide.backToCostumeLink
                                ]; //create array of links for menus
               
                for each (var links:MovieClip in linksArray)
                {
                    links.buttonMode = true;
                    links.mouseChildren = false;
                    links.addEventListener(MouseEvent.ROLL_OVER, onOver);
                    links.addEventListener(MouseEvent.ROLL_OUT, onOut);
                    links.addEventListener(MouseEvent.CLICK, onClick);
                }
               
                function onOver(e:MouseEvent):void
                {
                    TweenMax.to(e.target, 1, {glowFilter:{color:0xFFFFFF, alpha:1, blurX:10, blurY:10}}); //glow effect
                }
               
                function onOut(e:MouseEvent):void
                {
                    TweenMax.to(e.target, 1, {glowFilter:{color:0xFFFFFF, alpha:0, blurX:0, blurY:0, remove:true}}); //remove glow
                }
               
                function onClick(e:MouseEvent):void
                {
                    currentPage = e.target.name;

                    if (e.target.name == "newStoryLink") {

                        delegate.beginStory();
                       
                    } else if (e.target.name == "continueStoryLink") {
                       
                        //do something else

                    } else if (e.target.name == "selectChapterLink") {
                       
                        //do something else
                    }
    ...
    ...

    However, this code above doesn't work because any links that exist on other frame other than frame 1 will be null until I flip over to that frame. For example, all the main menu links "newStory" "continueStory" "options" etc will work, however links like "languageLink" and "chapter1Link" won't work, as these links only appear in later pages.
    So can anyone show me how I should create this menu? If using my method, how do I add listeners to all the links in the array regardless of what frames they exist on?

    Thanks.

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Any Movieclips or buttons, which you use for the links have to present in one frame block in all frames. You cannot interrupt the block by empty frames. Then you place your script in frame 1. Otherwise the menu will be recognized as a new object even it has the same name.
    - The right of the People to create Flash movies shall not be infringed. -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center