flash help - xml
- Started
- Last post
- 7 Responses
- spmitch0
oh, I see thanks
- acrossthesea0
Here's how I'd handle it:
assign an index, push to an array, access the array using the index
- spmitch0
yeah, I got that in there but its overwriting
var url:Srting = il.link[i];
- acescence0
var url:String = "blah";
var link:MovieClip = new Linky;
link.myurl = url;
addChild(link);
link.addEventListener(MouseEvent... getLink);function getLink(e:Event):void {
trace(e.target.myurl);
}
- spmitch0
it seems to be overwriting the url var because when i click on the button all the items go to the same link, but i can't figure out why
- acescence0
you need to access the specific movieclip's url variable via the event object that is passed to the getlink function.
- spmitch
the code below works except for the link url, it seems to just trace the last link url for all the list items any help would be great
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.CO... onLoaded);var xml:XML;
function onLoaded(e:Event):void {
xml = new XML(e.target.data);
var il:XMLList = xml.newoffers.item;
for (var i:uint=0; i<il.length(); i++) {
var listMC:MovieClip = new listMCMovieClip;
mc.addChild(listMC).name = "listMC" + i;
listMC.date.text = il.date[i];
listMC.description.text = il.description[i];
listMC.price.text = il.price[i];
var url:String = il.link[i].toString();
var link:MovieClip = new linkMovieClip;
mc.addChild(link).name = "link" + url;
link.addEventListener(MouseEvent... getLink);
function getLink(e:Event):void {
//var request:URLRequest = new URLRequest(url);
trace(url);
//navigateToURL(request, '_blank');
}