# as3 xml problem loading a url attribute NEED HELP!

**URL:** <https://forum.kirupa.com/t/as3-xml-problem-loading-a-url-attribute-need-help/251139>\
**Category:** Uncategorized\
**Created:** [February 5, 2008, 6:48pm UTC](https://forum.kirupa.com/t/as3-xml-problem-loading-a-url-attribute-need-help/251139 "2008-02-05T18:48:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cherryottis](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@cherryottis](https://forum.kirupa.com/u/cherryottis)\
**Post date:** [February 5, 2008, 6:48pm UTC](https://forum.kirupa.com/t/as3-xml-problem-loading-a-url-attribute-need-help/251139/1 "2008-02-05T18:48:34Z")

</div>

I am pulling a url from an attribute in the xml, but it writes over the variable in the for loop and I can’t figure out how to assign the link to the buttons in the for loop. interactiveContainer.viewProject is the button I want to open a link in a new window. url is the variable that I’m storing the projURL attribute from the xml too. I can load the attribute allright and I can trace the attributes from the xml. but when I try to assign the url to the buttons it only opens the last url in the xml and writes over the rest. this snippet of code is just a constructor and a couple of methods from the class, but essentially what I’m asking is how do you duplicate a button in a for loop and assign a specific url attribute to each button?

```
    public function InteractiveContent() {
        xmlLoader=new URLLoader ;
        xmlLoader.load(new URLRequest("xml/Portfolio.xml"));
        xmlLoader.addEventListener(Event.COMPLETE,loadXML);

    }
    private function loadXML(e:Event):void {
        xmlLoader=new URLLoader ;
        xmlLoader.load(new URLRequest("xml/Portfolio.xml"));
        xmlLoader.addEventListener(Event.COMPLETE,loadXML);
        function loadXML(e:Event):void {
            xml=XML(e.target.data);
            xmlList=xml.children();
            //trace(xmlList.length());

            for (var i:int; i &lt; xmlList.length(); i++) {
                imageURL=xmlList*.@imgSrc;
                title=xmlList*.@title;
                url=xmlList*.@projURL.toString();
                
                
                date=xmlList*.@date;
                imageLoader=new Loader ;
                imageLoader.load(new URLRequest(imageURL));
                interactiveContainer=new InterActiveContainer;
                interactiveContainer.y=450 * i + 190;
                imageLoader.y=50;

```

interactiveContainer.projectName.text=title;  
interactiveContainer.dateTime.text=date;

```
                addChild(interactiveContainer);
                                    
                interactiveContainer.addChild(imageLoader);
                       interactiveContainer.viewProject.addEventListener(MouseEvent.CLICK,callLink);

            }
            
        }

    }
        

    }
    private function callLink(e:MouseEvent):void {
        var request:URLRequest=new URLRequest(url);
        try {
            navigateToURL(request,"_blank");
        } catch (e:Error) {
            trace("Error occurred!");
        }
    }
```
