# Assigning functions to buttons in an array

**URL:** <https://forum.kirupa.com/t/assigning-functions-to-buttons-in-an-array/273912>\
**Category:** Uncategorized\
**Created:** [October 22, 2008, 1:53pm UTC](https://forum.kirupa.com/t/assigning-functions-to-buttons-in-an-array/273912 "2008-10-22T13:53:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fak](https://avatars.discourse-cdn.com/v4/letter/f/41988e/32.png) [@fak](https://forum.kirupa.com/u/fak)\
**Post date:** [October 22, 2008, 1:53pm UTC](https://forum.kirupa.com/t/assigning-functions-to-buttons-in-an-array/273912/1 "2008-10-22T13:53:53Z")

</div>

Hi people, this is my first post here, so bare with me…

I haven’t coded anything of significance the last few years, but now i’m trying to get into ActionScript 3, and… well, I’m having some problems with a slideshow I’m trying to make.

It loads the slide-data (image, heading, text and a URL for a Read More button) from a xml-file. The problem is that when I’m trying to create the eventlistener for the Read More button, all buttons get the value of the last slide.

Here’s the code

```auto
for (i=0; i<max; i++) {				
slide = new slideMc();
slide.x = -3000;
slide.y = 0;	
slide.alpha = 0;
slide.ready = false;

imgLoader = new Loader();
imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
imgLoader.load(new URLRequest(slideXML.article*.bigArticleImg));

slide.slideImg.addChild(imgLoader);

slide.heading.text = slideXML.article*.heading;
slide.ingress.text = slideXML.article*.ingress;
addChildAt(slide, i);

slideList.push(slide);
slideTable[imgLoader.contentLoaderInfo] = slide;

moreURL = slideXML.article*.readMoreLink;
slideList*.moreBtn.buttonMode = true;
slideList*.moreBtn.addEventListener(MouseEvent.MOUSE_UP,
function(evt:MouseEvent):void {
var request:URLRequest = new URLRequest(moreURL);

try {
navigateToURL(request, '_self');
} catch (err:Error) {
trace("Error occurred!");
}
}
);

```

If anyone’s interrested, the files for the project can be [downloaded here](http://frodekleven.com/yh/NordicSlideShow_v0.6.zip)

If i get the help to finish this, i’ll make the finished slideshow available as a free download if there’s interrest, so others can learn from it.

Thanks!
