PDA

View Full Version : Setting dynamic text with dynamic path's


05studios
12-07-2007, 02:23 PM
Hey guys,

I am pulling in this info with XML and trying to pass it thru a loop to plug in all of the news posts...however, for some reason, I cannot get the paths to work while I have a variable in it.

Any ideas?


import flash.net.*;
import flash.events.*;

var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
var numz:Number = 0;

xmlLoader.addEventListener(Event.COMPLETE, LoadXML);

xmlLoader.load(new URLRequest("news.xml"));


function LoadXML(e:Event):void {

xmlData = new XML(e.target.data);
ParseBooks2(xmlData);

}

function ParseBooks2(tourInput:XML):void {

var tourList:XMLList = tourInput.Newspost.datez;



for each (var dateElement:XML in tourList) {
// create entries newsTitle_txt

["newsButton"+numz+"_but"]addEventListener(MouseEvent.CLICK,onClick);

function onClick(e:Event):void{
trace(this)
//launch news story
}
// THIS IS WHERE I AM HAVING TROUBLE...ANY IDEAS? It pulls the info in, but I cant set this text using the variables..
var newsTitles:String = "newsButton"+numz+"_but.newsTitle_txt";
trace(this[newsTitles].text);
this[newsTitles].text = tourInput.Newspost.title.text()[numz];

numz++
}

}

this.stop();

Digital_Utopia
12-07-2007, 02:48 PM
variables in XML must be surrounded by brackets "{}"

05studios
12-07-2007, 02:51 PM
whatcha mean? where would i put them?