Thread: xml and flash

    #1
  1. No Profile Picture
    Certified Genius
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Location
    over there
    Posts
    77
    Rep Power
    13

    xml and flash


    i have a real simple xml doc (quickinfo.xml) with info about buildings in it that looks like this...

    <?xml version="1.0"?>
    <quickinfo>
    <building bname="Alumni House"
    description="Fenstemaker Alumni House built in 1967."
    instructions="Click left menu or building image." />
    </quickinfo>

    (more buildings than this)
    based on whatever button a user clicks it will load this info into a dynamic text field. however i can't get flash to get to the right part of the tree...this is just test code to see if i could get one of the building names to show up. (i took out the "if (success) {}" part and opted to just throw the value in the output window)

    quickinfo = new XML();
    quickinfo.onLoad = QIOnLoad;
    quickinfo.load("quickinfo.xml");
    function QIOnLoad (success) {
    trace("Success is " + success);
    var buildingListNode = this.firstChild;
    trace("Node bname: " + buildingListNode.childNodes[0].attributes.bname);
    }

    its prolly just a stupid error...as with all of my errors...thanks, rob
  2. #2
  3. No Profile Picture
    Certified Genius
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Location
    over there
    Posts
    77
    Rep Power
    13

    nevermind


    i got it...it was a combo problem between flashes problems with whitespace and my problem with book learnin...
  4. #3
  5. No Profile Picture
    Polynesian Monkey God
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2001
    Location
    Monkeytown, USA
    Posts
    57
    Rep Power
    13
    so what was the solution? was there actually an error in your actionscript aside from not accounting for whitespace?

    TotalMonkey
    "We're all - monkeys!" -- Jeffrey Goines, 12 Monkeys
  6. #4
  7. No Profile Picture
    Certified Genius
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Location
    over there
    Posts
    77
    Rep Power
    13

    solution


    one part of the problem is that when flash 5 first came out their xml handling was a bit screwy about carriage returns and whitespace...its kinda been fixed since build 30 or sumpin...but it has to be one straight line in order for older flash players to work well...the other issue i had was with flash not being able to handle text node aside from "parent nodes" so instead of having your data in tags like

    <id>1234567890</id>

    you have to have it in attributes like...

    <person id="1234567890"></person>

    third problem was my abismal failure of programming...to go deeper into nodes i figured i would just use notation like...

    mainnode.firstchild.firstchild and so on...

    so by that rational i just wrote...

    mainnode.firstchild.attributes.id

    but it worked when i changed it to

    myArray = new array;
    myArray = mainnode.childnodes;
    which returns an array of references to the children
    then myArray[x].attributes.id to grab the info i wanted...

    hopefully that makes sense...rob
  8. #5
  9. No Profile Picture
    Blabbermouth Wanker
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2002
    Location
    New York
    Posts
    60
    Rep Power
    13
    my advice, GO HERE , it's a prototype function by Branden at Figleaf that not only re writes the ignore whitespace to cover all flash 5 players, but also stops the flash lock up when parsing XML and allows you to show a preload bar of the XML data coming in.

    And it's free.

IMN logo majestic logo threadwatch logo seochat tools logo