A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: This here moron could use a little help loading XML

  1. #1
    Senior Member
    Join Date
    Jun 2000
    Posts
    100
    Hey'a,

    I've just started trying to get into loading XML with Flash 5. I'm not trying to do anything fancy for my first attempt, and I've been following along with one of the tutorials here, simplifying and modifying as I went, yet I am unable to get the data to load properly. Right now, I'd be happy, and able to do the rest(hopefully) if I could figure out why this is being so uncooperative.

    I'm running this off my Hard Drive as a testbed, not on a server, just in the Flash 5 "Test Movie" environment, if that makes a difference.

    Here's the A/S.

    Code:
    queryXML = new XML();
    pageXML = new XML();
    
    //Config
    targetFile = "primaryPage.xml";
    
    function loadPage (pageID) {
    	primaryContent.contentBox.daTextBox = "<br /><br /><br /><br /><p
     align=\"center\"><font size=\"+5\" color=\"#0000CC\">Loading Page</font><br /><font size=\"+2\" 
    color=\"#999999\">Please Wait, It Shouldn't Be 
    Long.</font></p>";
    
    	pageXML.onLoad = putPage();
    
    	pageXML.load(targetFile);
    }
    
    function putPage() {
    
    /*This is the problemo.
    It's not loading the XML, as far as I can tell.
    I doubt it has anything to do with Variable scope
    because when I moved it to the first function, just for the
    heck of it, it still didn't pass on through.*/
    
    	if(pageXML.loaded) {
    		primaryContent.contentBox.daTextBox = "<br /><br /><br /><br /><p align=\"center\"><font size=\"+5\" color=\"#0000CC\">Data Loaded</font><br /><font size=\"+2\" color=\"#999999\">Please Wait, It Shouldn't Be Long.</font></p>";
    
    		pageTag_XML = new XML();
    		elementTag_XML = new XML();
    
    		pageTag_array = new Array();
    		elementTag_array = new Array();
    	}
    }
    
    if (length(pageID)<=0) {
    	pageID = 1;
    	loadPage(pageID);
    }
    And just in case it's the XML..

    Code:
    <?xml version="1.0" encoding="iso-8859-1" ?>
    <page>
          <pageid>1</pageid>
          <section>index</section>
          <title>UIL Home</title>
          <content>Wills Point High School offers a large and successful academic UIL team.</content>
    </page>
    I'd appreciate any help that could be offered.

    -RCM

  2. #2
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035

    You are pretty close, just a couple of things need changing:

    Code:
    	pageXML.onLoad = putPage();
    should be:

    Code:
    	pageXML.onLoad = putPage;
    As you are referencing the function not calling the function at that point.

    Also in the putPage function don't try to reference the XML file but use 'this.'

    Also putPage function can/should take a variable.

    eg:

    function putPage(success)

    which tells you whether the XML page has successfully been loaded and been parsed!

    Thanks

    Luke

  3. #3
    Senior Member
    Join Date
    Jun 2000
    Posts
    100
    Hey Tupps,

    I'd already figured it out, but thanks for the tips. It took hours of fighting, reading posts(many of which were yours), etc. before I got the scripting worked out. Then I found a major killer by accident, a newline before my DTD statement was screwing with my nodes.

    Now I'm fighting a war with a scroll system based off of the second part to a scroller tute on this site that's not working when XML's loaded. But that's a topic for another forum.

    Thanks Tupps,
    -RCM

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