A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Help linking submenu items. please.

  1. #1
    Junior Member
    Join Date
    Sep 2009
    Posts
    7

    Help linking submenu items. please.

    Below is the code I am using. The submenu isn't physically on the stage it's only called in the actionscript. I have no idea how to make the "menu=Beauty, Location, Studio" link to new pages. Any ideas on how I can do this? I am clueless as to what code I would use and where I would put it. Any input would be greatly appreciated. Thank you.

    menu = ["Beauty", "Location", "Studio"];
    xStart = 662;
    yStart = 190;
    bWidth = 79;
    bHeight = 17;
    interval = 50;
    countDown = menu.length;
    menuOpen = false;
    theTime = 0;
    buttonScrollSpeed = 2;
    for (var i = 0; i<menu.length; i++) {
    var b = this.attachMovie("subButton", "subButton"+i, countDown);
    countDown--;
    b.stop();
    b._x = xStart;
    b._y = yStart;
    b.interval = interval*i;
    b.target = yStart+(bHeight*i);
    b.txt = b.page=menu[i];
    b.onPress = function() {
    closeMenu();
    _root.pages.gotoAndStop(this.page);
    this.gotoAndStop(1);
    };
    b.onRollOver = function() {
    this.gotoAndStop(2);
    };
    b.onRollOut = function() {
    this.gotoAndStop(1);
    };
    b._visible = false;
    }
    function closeMenu() {
    for (var i = 0; i<menu.length; i++) {
    var b = this["subButton"+i];
    b._visible = false;
    b._x = xStart;
    b._y = yStart;
    }
    menuOpen = false;
    }
    mainButton.onPress = function() {
    if (!menuOpen) {
    theTime = getTimer();
    menuOpen = true;
    for (var i = 0; i<menu.length; i++) {
    _root["subButton"+i]._visible = true;
    }
    } else {
    closeMenu();
    }
    };
    function scrollButtons() {
    if (menuOpen) {
    for (var i = 0; i<menu.length; i++) {
    var b = this["subButton"+i];
    if ((theTime+b.interval)<getTimer()) {
    b._y += (b.target-b._y)/buttonScrollSpeed;
    }
    }
    }
    }
    this.onEnterFrame = function() {
    scrollButtons();
    };

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    attached is a Flash 8 AS2 file
    it is a simplified version of your menu.

    on stage is a movieclip - instance name - pages
    this clip contains frame labels that match those in your menu array
    on each frame of this clip is a different page - page1, page2...
    Attached Files Attached Files

Tags for this Thread

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