A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: "_Level" Path Problem

  1. #1
    Junior Member
    Join Date
    Jun 2004
    Location
    The City of Dis, 666 Hates Drive
    Posts
    25

    "_Level" Path Problem

    I'm making an XML powered menu for my website and it works fine as a stand-alone movieclip on my stage. But when I nest it inside a few more movieclips it stops working and I don't see why.

    The original path was "_level0.m5d" but now since it's in a few more clips it should be "_level0.portfolioNavMC.p5dMC.m5d" but that doesn't seem to work.

    Here's my full script so you guys can give it a look over:
    code:

    var xmlData:XML = new XML();
    _level0.portfolioNavMC.p5dMC.m5d.xmlData.ignoreWhi te = true;
    _level0.portfolioNavMC.p5dMC.m5d.xmlData.load('m5d .xml');
    _level0.m5d.xmlData.onLoad = function():Void {
    _level0.m5d.qtd = this.childNodes[0].childNodes.length;
    for (i=0; i<qtd; i++) {
    _level0.portfolioNavMC.p5dMC.m5d.xmlMenu.duplicate MovieClip('xmlMenu'+i, _level0.portfolioNavMC.p5dMC.m5d.getNextHighestDep th());
    _level0.portfolioNavMC.p5dMC.m5d['xmlMenu'+i]._y += i*16;
    _level0.portfolioNavMC.p5dMC.m5d['xmlMenu'+i].t = this.childNodes[0].childNodes[i].childNodes[0].firstChild;
    _level0.portfolioNavMC.p5dMC.m5d['xmlMenu'+i].texto.text = _level0.portfolioNavMC.p5dMC.m5d['xmlMenu'+i].t.nodeValue;
    _level0.portfolioNavMC.p5dMC.m5d['xmlMenu'+i].link = this.childNodes[0].childNodes[i].attributes.link;
    _level0.portfolioNavMC.p5dMC.m5d['xmlMenu'+i].onRollOver = function() {
    loadMovie(this.link, this.previewMC);
    };
    _level0.portfolioNavMC.p5dMC.m5d['xmlMenu'+i].onRollOut = function() {
    unloadMovie(this.previewMC);
    };
    }
    _level0.portfolioNavMC.p5dMC.m5d.m5d.xmlMenu.unloa dMovie();
    };



    The only reason I can think of why this might not work is because "portfolioNavMC" is dynamically attached to the root timeline, but even when I just drag it onto the stage and apply the Instance Name that way it still doesn't work!

    Anyone have any ideas why I can't get this thing to work?
    Attached Files Attached Files
    ***Insert something clever***

  2. #2
    All 1s and 0s dmonkey's Avatar
    Join Date
    Nov 2005
    Location
    Leeds, UK
    Posts
    606
    Hi,

    The paths look pretty messy, and you really don't need them, so I chopped them down. The problem with the XML is that childNodes[0] seemed to be empty. I don't know much about using XML in Flash, so you'll have to look at that yourself. Here's how I changed the code, and at least one item came up correctly.

    code:

    var xmlData:XML = new XML();
    //Get rid of these long paths - we don't need them.
    xmlMenu.ignoreWhite = true;
    xmlData.load('m5d.xml');
    //Create a new variable that will act like a pointer to replace these long paths.
    var dPath:MovieClip = this;

    xmlData.onLoad = function():Void {
    //Again, no long path needed. qtd will be created at this level, as long as we don't prefix it with anything
    //For some reason, childNodes[0] comes up empty, so I had to use [1];
    qtd = this.childNodes[1].childNodes.length;
    //Also, this is coming up as 3, when really you only want 1. I'm not too hot on XML, so I don't know how to fix this.
    for (i=0; i<qtd; i++) {
    //xmlMenu exists at this leve, so again no long path needed
    xmlMenu.duplicateMovieClip('xmlMenu'+i, _level0.portfolioNavMC.p5dMC.m5d.getNextHighestDep th());
    //Here, I have to use dPath to reference this level since you want to use array access operators
    dPath['xmlMenu'+i]._y += i*16;
    //Again, I had to change these to [1] to get any kind of output
    dPath['xmlMenu'+i].t = this.childNodes[1].childNodes[i].childNodes[1].firstChild;
    dPath['xmlMenu'+i].texto.text = dPath['xmlMenu'+i].t.nodeValue;
    dPath['xmlMenu'+i].link = this.childNodes[1].childNodes[i].attributes.link;
    dPath['xmlMenu'+i].onRollOver = function() {
    loadMovie(this.link, this.previewMC);
    };
    dPath['xmlMenu'+i].onRollOut = function() {
    unloadMovie(this.previewMC);
    };
    }
    xmlMenu.unloadMovie();
    };



    Hope this helps.
    "If I have seen further, it is by standing on the shoulders of giants." - Sir Isaac Newton

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