A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [RESOLVED] AS2 - Arrays to textbox

  1. #1
    Member
    Join Date
    Sep 2001
    Posts
    72

    resolved [RESOLVED] AS2 - Arrays to textbox

    I need to pull data from an xml array, then have it alternate listing the data in the same text box.

    Here is the how I'm loading the XML:

    Code:
    // LOAD XML
    loadXML = function (loaded) {
    	if (loaded) {
    		xmlNode = this.firstChild;				
    		contentBorder = Number(xmlNode.childNodes[0].attributes.Border);
    		contentWidth = Number(xmlNode.childNodes[0].attributes.Width);
    		contentHeight = Number(xmlNode.childNodes[0].attributes.Height);
    		txt_mc.txthead.htmlText = xmlNode.childNodes[0].firstChild.nodeValue;
    		txt_mc.txt.htmlText = datecom + xmlNode.childNodes[1].firstChild.nodeValue;						
    		headerName.text = xmlNode.attributes.Name;
    
    }
    	} else {
    		trace("Error loading XML");
    	}
    };
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;
    if (_root.toLoad == undefined) {
        _root.toLoad = "dailylog.xml";	
    }
    xmlData.load(_root.toLoad);
    Here is my conceptual approach (but to no success):

    Code:
    // LOAD XML
    loadXML = function (loaded) {
    	if (loaded) {
    		xmlNode = this.firstChild;				
    		contentBorder = Number(xmlNode.childNodes[0].attributes.Border);
    		contentWidth = Number(xmlNode.childNodes[0].attributes.Width);
    		contentHeight = Number(xmlNode.childNodes[0].attributes.Height);
    		txt_mc.txthead.htmlText = xmlNode.childNodes[0].firstChild.nodeValue;
    		for (i=0; i<total; i++) {
        headline[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
        copy_full[i] = xmlNode.childNodes[i].childNodes[5].firstChild.nodeValue;
    }
    txt_mc.txt.htmlText = datecom + headline[i]+"\n"+copy_full[i];
    }
    }
    	} else {
    		trace("Error loading XML");
    	}
    };
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;
    if (_root.toLoad == undefined) {
        _root.toLoad = "dailylog.xml";	
    }
    xmlData.load(_root.toLoad);
    Here is the result I need displayed in the texbox:

    FLASHBACK - OBAMA ON AIG BONUSES --- (headline[0])

    Obama talks about the executive bonues at AIG. He talks about how they are in financial distress due to greed.
    (021010OLDOBAMA01) Q… greed Time ¬ 16 seconds --- (copy_full[0])

    He talks about how it’s hard to understand how AIG awarded these bonues and how can they justify this to the taxypayers.
    (021010OLDOBAMA02) Q… afloat Time ¬ 18 seconds --- (copy_full[0])

    Obama then says he is asking Sect. Geitherner to use every single possible way to block the bonuses.
    (021010OLDOBAMA03) Q… applause Time ¬ 18 seconds --- (copy_full[0])

    BIDEN GAFFE - IRISH PM'S MOTHER --- (headline[1])

    Biden, talking about the mother of the Irish PM, says God rest her soul- oh wait, she’s still alive- God bless her soul! I gotta get this straight!
    (031810BIDENGAFFE) Q…straight Time – 21 seconds --- (copy_full[1])

    ETC. --- (headline[2])

    ETC. --- (copy_full[2])

    ETC. --- (headline[3])

    ETC. --- (copy_full[3])

    Here is a condensed version of the xml being loaded:

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <content>
    <article>
    <headline>FLASHBACK - OBAMA ON AIG BONUSES</headline>
    <date>2010 November 14</date>
    <copy_intro><![CDATA[<p>Obama flashback in March of 2009 on AIG and financial responsibility</p>]]></copy_intro>
    <image_thumb>DailyAudio/Pics/ ObamaAIGSmall.jpg</image_thumb>
    <image_large>DailyAudio/Pics/ObamaAIGBig.jpg</image_large>
    <copy_full><![CDATA[<p>Obama talks about the executive bonues at AIG. He talks about how they are in financial distress due to greed.
    <font color="#666666">(021010OLDOBAMA01) Q… greed Time ¬ 16 seconds</font><br>He talks about how it’s hard to understand how AIG awarded these bonues and how can they justify this to the taxypayers.
    <font color="#666666">(021010OLDOBAMA02) Q… afloat Time ¬ 18 seconds</font><br>Obama then says he is asking Sect. Geitherner to use every single possible way to block the bonuses.
    <font color="#666666">(021010OLDOBAMA03) Q… applause Time ¬ 18 seconds</font><br>He then makes sure to let everyone know that Sect Geithner is on the case and is going to get things solved.
    <font color="#666666">(021010OLDOBAMA04) Q… last year Time ¬ 16 seconds</font><br>Obama then says that this is not just a matter of dollars and cents. It’s about fundamental values. He then talks about Americans meeting their responsibilities without bailouts or bonuses.
    <font color="#666666">(021010OLDOBAMA05) Q… bonuses Time ¬ 20 seconds</font><br>Obama then talks about people forgoing pay so they can just keep their credit line open and keep their mortgages.
    <font color="#666666">(021010OLDOBAMA06) Q… a float Time ¬ 20 seconds</font><br>He says that the main thing that these people on “main street” want is for Wall Street to be held to the same standards.
    <font color="#666666">(021010OLDOBAMA07) Q… again Time ¬ 20 seconds</font><br>Obama talks about how there should be some form of resolution mechanism that protects Americans and the financial system just in case this happens again.
    <font color="#666666">(021010OLDOBAMA08) Q… as this Time ¬ 12 seconds</font><br>Obama then makes a joke about how he is choked up with angery.
    <font color="#666666">(021010OLDOBAMA09) Q… here Time ¬ 10 seconds</font><br>He says that they, the government, have some form of resolution to deal with banks but with companies like AIG, the government doesn’t.
    <font color="#666666">(021010OLDOBAMA10) Q… here Time ¬ 23 seconds</font><br></p>]]></copy_full>
    </article>

    <article>
    <headline>BIDEN GAFFE - IRISH PM'S MOTHER</headline>
    <date>2010 November 14</date>
    <copy_intro><![CDATA[<p>Biden stating the mother of the Irish PM is dead, when she’s very much alive.</p>]]></copy_intro>
    <image_thumb>DailyAudio/Pics/BidenSmall.jpg</image_thumb>
    <image_large>DailyAudio/Pics/BidenBig.jpg</image_large>
    <copy_full>
    <![CDATA[<p>Biden, talking about the mother of the Irish PM, says God rest her soul- oh wait, she’s still alive- God bless her soul! I gotta get this straight!
    <font color="#666666">(031810BIDENGAFFE) Q…straight Time – 21 seconds</font><br></p>]]>
    </copy_full>
    </article>

    <article>
    <headline>CLINTON SAYS ISRAEL INSULTED USA</headline>
    <date>2010 November 14</date>
    <copy_intro><![CDATA[<p>Secretary of State Hillary Clinton says Israel insulted the United States with Jerusalem settlement announcement</p>]]></copy_intro>
    <image_thumb>DailyAudio/Pics/HClintonSmall.jpg</image_thumb>
    <image_large>DailyAudio/Pics/HClintonBig.jpg</image_large>
    <copy_full><![CDATA[<p>Clinton says our ……etc, etc, etc.</p>]]>
    </copy_full>
    </article>
    </content>

    Any and all help on this is greatly appreciated. Thanks for taking a moment to help out a newbie!!!

    Kumba

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    this?

    Actionscript Code:
    headline = new Array();
    copy_full = new Array();

    loadXML = function (loaded) {
        if (loaded) {
            xmlNode = this.firstChild;             
            childNodes = xmlNode.childNodes.length;
            contentBorder = Number(xmlNode.childNodes[0].attributes.Border);
            contentWidth = Number(xmlNode.childNodes[0].attributes.Width);
            contentHeight = Number(xmlNode.childNodes[0].attributes.Height);
            txt_mc.txthead.htmlText = xmlNode.childNodes[0].firstChild.nodeValue;
            for (i=0; i<childNodes; i++) {
                headline[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
                copy_full[i] = xmlNode.childNodes[i].childNodes[5].firstChild.nodeValue;
            }
            trace(copy_full[0]);
            txt_mc.txt.htmlText = "";
            for(a=0; a<childNodes; a++){
                txt_mc.txt.htmlText += datecom + headline[a]+"\n"+copy_full[a];
            }
        } else {
            trace("Error loading XML");
        }
    };
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;
    if (_root.toLoad == undefined) {
        _root.toLoad = "dailylog.xml"
    }
    xmlData.load(_root.toLoad);

    and please don't double post!
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Member
    Join Date
    Sep 2001
    Posts
    72
    Hi Nig 13,

    What you wrote gave me enough foundation to accomplish what I needed, thank you very much! I greatly appreciate it.

    Also, I have tried multiple times to delete my first post using the "edit" button but there is nowhere on the page to delete the entire post. Am I missing something?

    Thanks, again!
    Kumba

  4. #4
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    No problem, and forget about deleting your post

    ( because only mods can do that, I think )
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

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