A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: xml variables

  1. #1
    Junior Member
    Join Date
    May 2007
    Posts
    5

    xml variables

    i could do with a bit of help with a flash script that I am trying to write, I have a xml file with the updates to my website that is configured as follows:

    <?xml version="1.0"?>
    <database>
    <entry>
    <date>7/05/07</date>
    <mod>After a few weeks away, some minor additions and modifications to some sections</mod>
    <end>notend</end>
    </entry>
    <entry>
    <date>pre 2007</date>
    <mod>data will only be stored for the current year</mod>
    <end>end</end>
    </entry>
    </database>


    and my script that I am using is as follows:

    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;
    xmlData.load("news.xml");
    function loadXML(loaded) { _root.date = this.firstChild.childNodes[mynumber].childNodes[0].firstChild.nodeValue;
    _root.mod = this.firstChild.childNodes[mynumber].childNodes[1].firstChild.nodeValue;
    name_txt.text = _root.date;
    comment_txt.text = _root.mod;
    }

    I have a flash file on www.darrensmith.org.uk that scrolls through the xml file using a set of buttons changing the "mynumber" variable. that works fine until I get to the last entry. I have been trying to get it to stop and not go any further. My question is how do I use the data in <end> node of the xml file to direct the last sequence to another frame that does not have the next sequence button

  2. #2
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    I'm not a fan of using a node value to base navigation movements on for a few reasons not worth mentioning. It's usually far better in my experience to base count on array totals so no matter how many childNodes are read in...the count is always spot on.

    Instead of just spouting out a bunch of confusing explanations...I made you a simple example that maybe will help ...attached below

    The xml I used for the example is commented out in the actions panel.
    Attached Files Attached Files

  3. #3
    Junior Member
    Join Date
    May 2007
    Posts
    5
    Chris, your code has helped me a lot, I now understand how the arrays work and I have taken sections of your code for my own site, you have also got a mention in the latest news on the site

  4. #4

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