dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: accessing arrays/mc's in xml menu

  1. #1
    Senior Member
    Join Date
    Mar 2001
    Posts
    247

    accessing arrays/mc's in xml menu

    I'd really appreciate some help here. I'm tying myself up in knots.

    It's an XML-driven menu with three levels in the hierarchy. Top level is categories, then there's a sub-menu under each category that contains the bottom level, the buttons. I know I probably don't really need the sub-menu level.

    So the XML is read in fine and I have my hiearchy of movie clips like - menu0.submenu0.submenu_btn0. But I'm lost as to how to target the submenu or buttons of the current menu. I have a variable (currentMenu) that increments and gives me a number I can use to target the currently selected menu (using the menuSelect array).

    What I actually need to do is create an infinite menu (not constantly moving - moves with right and left clicks) with the submenu buttons. So I need to keep track of which menu and which submenu button is selected, and move the submenu buttons appropriately when the user clicks 'left' or 'right'.

    Anyway, here's the script ....
    code:

    var currentMenu:Number = 0;
    var menu:Array = new Array();
    var menuSelect:Array = new Array();
    var menuName:Array = new Array();
    var submenu_mcs:Array = new Array();
    _root.btn_left.onRelease = function() {
    // HOW DO I TARGET THE SUBMENU AND/OR THE INDIVIDUAL BUTTONS OF THE currentMenu HERE?
    };
    function CreateMenu(menu_xml) {
    menu = menu_xml.firstChild.childNodes;
    for (var i = 0; i<menu.length; i++) {
    menuName.push(menu[i].attributes.name);
    var p:Number = i;
    var init:Object = {x:x, y:y, z:z, menuName:menuName, p};
    menu_mc = space.attachMovie("menu", "menu"+i, 0-i, init);
    menuSelect.push(menu_mc);
    var submenu:Array = new Array();
    var submenuName:Array = new Array();
    submenu = menu[i].childNodes;
    submenu_mc = menu_mc.createEmptyMovieClip("submenu"+i, i);
    submenu_mcs.push(submenu_mc);
    var btnPos:Number = 0;
    for (var j = 0; j<submenu.length; j++) {
    submenu_btn = submenu_mc.createEmptyMovieClip("submenu_btn"+j, j);
    submenu_btn._x = btnPos;
    btnPos += 100;
    submenuName.push(submenu[j].attributes.name);
    }
    }
    }
    var content_xml = new XML();
    content_xml.ignoreWhite = true;
    content_xml.onLoad = function(success) {
    if (success) {
    CreateMenu(this);
    } else {
    trace("Error loading XML file");
    }
    };
    content_xml.load("content.xml");




    Please help!
    mark
    flash8

  2. #2
    Senior Member
    Join Date
    Mar 2001
    Posts
    247
    Ok. Forget the XML. Say I have a hierarchy of movie clips as below ....

    menu0.submenu0.submenu_btn0
    menu0.submenu0.submenu_btn1
    menu0.submenu0.submenu_btn2

    menu1.submenu1.submenu_btn0
    menu1.submenu1.submenu_btn1
    menu1.submenu1.submenu_btn2

    .... etc, that have been dynamically created. How do I go about organising access to the buttons? How to I target/access them to, for example, 'move menu0.submenu0.btn0 100 to the right but move the rest of menu0 buttons to the left'?

    thanks
    mark
    flash8

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