A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: ::: Help understanding a piece of code :::

  1. #1
    Senior Member
    Join Date
    Aug 2000

    ::: Help understanding a piece of code :::

    im now using XML for my news blogger in flash...

    im using this piece of code in flash to call the xml

    _root.news = _root.news;
    _root.news = _root.news+(newsData.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue+");
    _root.news = _root.news+(newsData.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue+");
    _root.news = _root.news+("+newsData.firstChild.childNodes[i].childNodes[2].firstChild.nodeValue+"
    _root.news = _root.news;

    i dont quite understand it

    can u help me
    Last edited by sweetdude_uk; 05-10-2003 at 02:30 PM.

  2. #2
    Senior Member
    Join Date
    Feb 2001

    first off, some "" characters seem to have gone missing from the code. Also, the first and last lines (_root.news = _root.news) are completely superfluous, they do nothing at all - you can delete them.

    What you are left with should be in a loop, is that right? In each pass of the loop, more data is added to the textfield with variable name 'news', in the main timeline.

    The data is extracted from the XML document as follows:

    newsData - the XML object
    firstChild - goes inside the outermost, all-enclosing tag pair
    childNodes[i] - goes inside the 'ith' 2nd level tag
    childNodes[0/1/2] - goes inside the 1st/2nd/3rd tag inside the 'ith' tag
    firstChild.nodeValue - grabs the text inside the tag

    If you follow this with the actual XML document, it should make sense.

    - n.

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