Dynamically assigning functions to button events results in problems

Hi all,

I was wondering if someone might be able to assist with an issue that I am encountering with a project that I am currently working on.

I am in the process of writing a scrolling image viewer that dynamically updates from an xml file. I have written the scroll function (with a lot of help from Kirupa and other sources), and the pictures are updating beautifully, but when it comes to adding the function for the buttons I am encountering an unusual error.

Using the following code:

 for (var i in btnArray) {  
      var btn:MovieClip = btnArray*;
  btn.onRelease= doClick();

from this site results in the doClick function being called for each of the buttons in the btn array at runtime, and then not working afterwards. I have included the code if it helps.

Help me Kirupa, you’re my only hope! :vader:
Thank you in advance