A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: xml nav help

  1. #1
    Member
    Join Date
    Apr 2006
    Posts
    30

    xml nav help

    Hi,

    I have a small problem with xml navigation.

    The nav is built and working fine the problem is I dont know how to make each button show a selected / active state.

    I can make the button turn yellow and become disabled, stopping the rollout function.
    this works but when I press another button it doesn't set the one pressed before it to return to its original state.

    Because the menu it populated via xml and the movieclips are attached I am not sure how to reference them individually.

    If any one could help that would be brilliant.

    thanks


    this the code =

    menu_xml = new XML();
    menu_xml.ignoreWhite = true;
    menu_xml.onLoad = function(ok) {
    if (ok) {
    CreateMainMenu(245,132,1,this);
    message_txt.text = "message area";
    } else {
    message_txt.text = "error: XML not successfully loaded";
    }
    };
    menu_xml.load("nav.xml");


    GenerateMenu = function (container, name, x, y, depth, node_xml) {;
    var info_item;
    var curr_node;
    var curr_item;
    var totalNav = curr_item.length;
    var curr_menu = container.createEmptyMovieClip(name, depth);
    for (var i = 0; i<node_xml.childNodes.length; i++) {;

    // projects buttons;
    curr_item = curr_menu.attachMovie("menuitem", "item"+i+"_mc", i);
    curr_item._x = x;
    curr_item._y = y+i*curr_item._height;
    curr_item.trackAsMenu = true;
    ///load project nodes;
    curr_node = node_xml.childNodes[i];
    curr_item.action = curr_node.attributes.action;
    curr_item.variables = curr_node.attributes.variables;
    curr_item.name.text = curr_node.attributes.name;

    //set project button states;
    curr_item.onRelease = function() {
    trace("click");
    Actions[this.action](this.variables);
    };

    CreateMainMenu = function (x, y, depth, menu_xml) {
    GenerateMenu(this,"mainmenu_mc",x,y,depth,menu_xml .firstChild);
    };

    // loads swf into holder
    Actions = Object();
    Actions.gotoURL = function(urlVar) {
    vid_holder.loadMovie(urlVar);
    };

  2. #2
    Multimedia Samurai
    Join Date
    Oct 2000
    Location
    Minneapolis, MN
    Posts
    95
    it looks like your onRelease handler performs whatever action it found in the XML but I don't see where you're tracking the currently highlighted item. Usually I use a variable to store the instance name of the currentItem and then upon click, revert the state of currentItem to default before performing the desired button action & updating the currentItem variable to contain a pointer to the most recently clicked button.

    you have a variable named curr_item but that's just used to generate the menu and it doesn't exist once GenerateMenu finishes running since your var declaration is inside the function.
    "Art washes from the soul the dust of everyday life."
    - Pablo Picasso

    Computer Animation and Digital Art by Matt Weier

  3. #3
    Member
    Join Date
    Apr 2006
    Posts
    30
    Thanks for you reply,

    I think i understand what you mean, do you think you could help me add the extra variable that i need so I can call the buttons individually.

    Any help with the code would be great.

    thanks

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