dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Naming/path question.

  1. #1
    Local Dissembler
    Join Date
    Sep 2002
    Posts
    9

    Naming/path question.

    I set up an example of my problem.

    PHP Code:
    _root.savePath "myXML.firstChild.childNodes[0].firstChild.nodeValue"

    saveXML.onRelease = function() { 
        
    myXML.firstChild.childNodes[0].firstChild.nodeValue editNews.text //is replacing the nodeValue with editNews.text 
        
    _root[savePath] = editNews.text//is not replacing the nodeValue with editNews.text 
    }; 

    The problem is, the first replacement action works, the second one doesn't. What I'm trying to figure out is, why?
    And how, if possible, can I get the latter working?

    Thanks a lot,
    Timothy.

  2. #2
    Senior Member
    Join Date
    Feb 2004
    Location
    California
    Posts
    174
    when you use the array operator to reference an MC it can only be 1 MC; ie you cannot use the dot operator to chain MCs together:

    ex
    code:

    //you cannot do this
    var path = "one_mc.two_mc";
    _root[path]._x = 10;

    //don't use the dot operator to chain and it works
    var path = "one_mc";
    _root[path]._x = 10;



    so you need to use a different method to globalize this variable. just use an actual node and not a string acting as a path:

    ex
    code:

    saveNode = myXML.firstChild.childNodes[0].firstChild;

    saveXML.onRelease = function() {
    saveNode.nodeValue = editNews.text;
    };


  3. #3
    Local Dissembler
    Join Date
    Sep 2002
    Posts
    9
    This "myXML.firstChild.childNodes[0].firstChild.nodeValue" path must be a string.

    What you're saying is, well first, say that myXML.firstChild.childNodes[0].firstChild has the value "This is the first child text."

    If you say that the variable saveNode = myXML.firstChild.childNodes[0].firstChild;
    Then you'll get this, according to your example.

    This is the first child text.nodeValue = editNews.text;

    Maybe I'm crazy, but this definately doesn't make sense.
    Or maybe I just really have no idea what I'm doing.

  4. #4
    Local Dissembler
    Join Date
    Sep 2002
    Posts
    9
    Got it.

    This is the solution, in case this helps anyone else.

    var savePath = "myXML.firstChild.childNodes.0.firstChild";

    saveXML.onRelease = function () {
    var node = eval (_root.savePath);
    node.nodeValue = editNews.text;
    };

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