A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: menu system

  1. #1
    Member
    Join Date
    Jul 2004
    Posts
    68

    menu system

    This is quite a big problem I got. I am doing a big menu system with lots of sub menus.
    exp:
    when I click on Button A I want A to open B & C to close down.
    when I clik on button B I want B to open and A & C to close down
    when I click on button C I want C to open and A & B to close

    This is my way of working;
    on (release) {
    tellTarget (_root.A) {
    gotoAndStop("show");
    }
    }
    on (release) {
    tellTarget (_root.B) {
    gotoAndStop("hide");
    }
    }
    on (release) {
    tellTarget (_root.C) {
    gotoAndStop("hide");
    }
    }

    It works fine for small projects but it is very slow and gets confusing with biger projects.

    Is there a better way of working.
    Help Appritiated..
    Thanks

  2. #2
    ActionScript Insomniac
    Join Date
    Jan 2003
    Location
    43d03.21'N, 89d23.65'W
    Posts
    1,173
    Unless you really need to be compatible with Flash 4, you should use modern syntax.

    Give each button an associated menu, and put all menus in an array. Something like this:

    Code:
    menus = [menuA, menuB, ...];
    buttonA.menu = menuA;
    buttonB.menu = menuB;
    
    buttonA.onRelease = setMenus;
    buttonB.onRelease = setMenus;
    
    function setMenus() {
    for(var i in menus) {
      if(menus[i] == this.menu) {
           menus[i].gotoAndStop("show");
       }  else {
           menus[i].gotoAndStop("hide");
       }
    }
    Unless otherwise specified, all code goes in Frame 1 of main timeline. FlashGizmo.com

  3. #3
    Member
    Join Date
    Jul 2004
    Posts
    68
    Hi mkantor,

    This is the sample of how I work. I know it is very complecated way of doing things(and takes lots of time).

    I would like to use the modern syntax. But I had a bit of a problem while trying to achieve that. Will it be possible to tweek with my sample and send it back for me to see how it works.

    thank you
    Zorra
    Attached Files Attached Files

  4. #4
    ActionScript Insomniac
    Join Date
    Jan 2003
    Location
    43d03.21'N, 89d23.65'W
    Posts
    1,173
    No, sorry. I hate dealing with old-style code. But here is a working example of a good way to do it.
    Attached Files Attached Files
    Unless otherwise specified, all code goes in Frame 1 of main timeline. FlashGizmo.com

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