dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Load xml into textArea using button

  1. #1
    Member
    Join Date
    May 2008
    Posts
    70

    Load xml into textArea using button

    Hi, this is very basic so please bare with me. I am trying to load particular parts of an xml into a textArea. When the movie starts the first node of the xml should load into the textArea and when the btn1 is clicked the second node should replace the first node. I am working in CS3 using AS2. I would really appreciate some help as I can't get it to work and keep getting an 'undefined' message, I have pasted my code and xml in below.

    My Action script
    loadtextContent = new XML();
    loadtextContent.ignoreWhite = true;
    loadtextContent.load("chapter.xml");

    mytextbox.html = true;
    mytextbox.wordWrap = true;
    mytextbox.multiline = true;

    import mx.styles.CSSStyleDeclaration;
    _global.styles.TextInput.setStyle("backgroundColor ", "transparent");
    _global.styles.TextInput.setStyle("borderStyle", "none");

    textArea.htmlText = aNode[0].childNodes[1].firstChild.nodeValue;

    loadtextContent.onLoad = function(){
    aNode = this.firstChild.childNodes;
    myText.htmlText = content.childNodes[0].firstChild.nodeValue;
    };

    btn1.onRelease = function() {
    textArea.text = aNode[0].childNodes[1].firstChild.nodeValue;
    }



    My XML:
    <?xml version="1.0" encoding="utf-8"?>

    <chapter>

    <info><![CDATA[<b>This text should show in the textArea box when the movie starts</b>]]></info>

    <info><![CDATA[This text should load into the textArea when btn1 is clicked]]>
    </info>


    </chapter>
    Last edited by Embussy; 01-17-2009 at 11:45 PM.

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    push each node value into an array and cycle thro' the array on button event
    PHP Code:
    arr = [];

    _xml = new XML();
    _xml.ignoreWhite true;
    _xml.load("chapter.xml");

    _xml.onLoad = function(){
    aNode this.firstChild.childNodes;
    len aNode.length;
    for(var 
    n=0;n!=len;n++){
    arr.push(aNode[n].firstChild.nodeValue);
    }
    myTA.html true// textArea component
    myTA.text arr[0];
    }; 

    btn1.onRelease = function() {
    myTA.text arr[1];


  3. #3
    Member
    Join Date
    May 2008
    Posts
    70
    a_modified_dog thank you so much it's brilliant!!!

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