A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Change dynamic text field's xml "value"

Hybrid View

  1. #1
    Junior Member
    Join Date
    Dec 2008
    Posts
    7

    Question Change dynamic text field's xml "value"

    Hello.

    Here is the problem I am facing now!

    I want to load an xml value "name [0]" to a dynamic text field which is into a movie clip.
    The movie clip will loop, each time the timeline starts again from frame one ( of the movie clip) I would like to load the same value of the subsequent childnode "name[1]". When the maximum number of values is reached the changing of the values will stop.

    <?xml version="1.0" encoding="utf-8"?>
    <polls>
    <poll >
    <answers>
    <answer>
    <name>Michael</name>
    <tally>0</tally>
    <image>www.clipart.com/test.jpg</image>
    </answer>
    <answer>
    <name>Sophie</name>
    <tally>0</tally>
    </answer>
    </poll>
    </polls>

    I have made various attempts but nothing works.

    Any hints please?
    Thanks.

  2. #2
    Junior Member
    Join Date
    Dec 2008
    Posts
    7

    Angry

    I have used this actionscript.

    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;
    xmlData.load("anim1.xml");

    //this function loads the names[0] value in the movie clip.
    function loadXML(loaded) {
    tmp = [];
    names = [];
    images = [];
    xmlNode = this.firstChild.firstChild.firstChild.childNodes;
    len = xmlNode.length;

    i=0;
    tmp[i] = xmlNode[i].childNodes;
    names.push(tmp[i][0].firstChild.toString());
    images.push(tmp[i][1].firstChild.toString());
    _root.posost.valueTXT.text=names[i];

    }
    //this action is called in the last frame of the movie clip
    function increment (){
    i++;
    _root.posost.valueTXT.text="";
    tmp[i] = xmlNode[n].childNodes;
    names.push(tmp[i][0].firstChild.toString());
    trace(i);
    if (i>len){
    _root.gotoAndStop(5);
    }else{
    _root.posost.valueTXT.text=names[i];


    }
    }



    It doesn't change the value of the text field it says undefined. I traced i and it increments as coded, and when i>len is true it goes to the frame specified.
    Last edited by Nasiapostol; 12-18-2008 at 11:08 AM.

  3. #3
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    you use -
    //this action is called in the last frame of the movie clip
    tmp[i] = xmlNode[n].childNodes;

    where is the value of n coming from ?

  4. #4
    Junior Member
    Join Date
    Dec 2008
    Posts
    7
    I am not using "n" anywhere.
    I just forgot to correct it, it should be "i"!
    Sorry ;(...

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