dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: XML MC within a MC

Hybrid View

  1. #1
    Junior Member
    Join Date
    Feb 2001
    Posts
    1
    I would be eternally grateful if someone even has a clue on this problem.

    I have been working with the XML and Flash 5 Tutorial on Flashkit and have a Movie clip with a textbox that points to the XML document and a layer with actions (just stop) and a labels layer.

    This MC works like a charm when I go to test the scene.

    When I place this in my main MC, it stalls on the loading data section.

    THe code is below:

    urlXML = new XML();
    urlXML.theMC = this;
    urlXML.onLoad = convertXML;


    content_feed_display = "Loading data...";
    urlXML.load("moreover.xml");


    function convertXML() {
    if(this.loaded) {
    content_feed_display = "Data loaded.";
    }
    mainTag = new XML;
    elementTag = new XML;
    articleList = new Array;
    elementList = new Array;

    //first get a handle on the first actual element in the document.
    //note we skip to the nextSibling element, since the first element
    //is a document definition tag.
    mainTag = this.firstChild.nextSibling;
    //make sure we have the right parent tag. Do this by looking at the nodeName property
    //for this object. This will correspond exactly to the <nodeName>, where nodeName is replaced
    //with the name of your xml tag
    if(mainTag.nodeName.toLowerCase() == "moreovernews") {
    //if we have a match, we collect all of the articles beneath it as an array of xml objects
    articleList = mainTag.childNodes;
    //now we loop over all the articles and look for the tags we are looking for...
    content_feed_display = "";
    for(i=0;i<=articleList.length;i++){
    //initialize a couple of variables to hold xml data we want displayed
    document_url = "";
    headline_text = "";
    if(articleList.nodeName.toLowerCase() == "article") {
    //we get the child node array beneath the articles, aka the meat and potatoes we are after
    elementList = articleList.childNodes;
    //and loop through that looking for the data we need
    for(j=0;j<=elementList.length;j++) {
    elementTag = elementList[j];
    elementType = elementTag.nodeName.toLowerCase();
    if(elementType == "headline_text"){
    headline_text = elementTag.firstChild.nodeValue;
    } else {
    if(elementType == "url"){
    url = elementTag.firstChild.nodeValue;
    }

    }
    }
    content_feed_display += "<p><font size=\"+2\"><a href=\""+url+"\" target=\"_new\">"+ headline_text +"</a></font></p>";
    }
    }


    }



    }



    Is there a way to get this to work? It is the answer to all my prayers! I know that it must be something in the way that the "this." part of the script.

    Thank you in advance for your help.




  2. #2
    Where is the xml tutorial? I can't find it. All I see is 4 tutorials relating to "dymanic content", but nothing about xml per se. Where do I need to look?

    Thanks!

  3. #3
    Member
    Join Date
    Jul 2000
    Posts
    75
    Originally posted by dbonneville
    Where is the xml tutorial? I can't find it. All I see is 4 tutorials relating to "dymanic content", but nothing about xml per se. Where do I need to look?

    Thanks!
    Here it is:
    http://www.flashkit.com/tutorials/3rd_Party/Flash_5_-Chris_Sm-213/index.shtml

    -k

  4. #4
    Junior Member
    Join Date
    Mar 2001
    Posts
    20
    Yes I did that tutorial -- it works just fine... I think you may have to change what is inside the LOAD string.

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