views:

311

answers:

0

Hi guys,

I'm trying to populate a list of buttons with results from a xml picture list in AS2. These buttons will load the resulting image from the xml. I'm populating the buttons by first getting the number of results in the xml, and then using a for loop to attachMovie the require number of buttons and assign the actions to them.

The problem now is that the handler function which assigns the load functions to it don't seem to be receiving the variable I tried to pass, therefore it's not working.

ps: i'm using attachMovie with a MC with a btn inside it, because when I tried to attachMovie the btn itself, for some reason I couldn't do any positioning with it at all..infact, I couldn't reference it at all for some reason.

Can anyone help me out please? It would be greatly appreciated. Code is as follow:

     photos_xml.onLoad = function(success) {  
        if (success) {
        imageList = photos_xml.firstChild.childNodes;
      _root.imageLength = imageList.length;
      loadImage();
        } else {
            trace("Error loading photos_xml");  
        }
     initButtons();
     loadImage(0);
    }

    function initButtons() {
     for(x=0;x<imageList.length;x++)
     {
      y=x+1;
      _root.attachMovie("test","btn_mc"+y,10+x,{_x:847.1-(x*77),_y:501,onPress:function() { btn_handler("btn_mc"+y,x); }});
     }
     btn_mc1.btn.enabled = false;
     btn_mc1.btn._alpha = 0;
     TweenMax.to(btn_mc1.btn, 0.5, {blurFilter:{blurX:100, blurY:100}});
    }

function btn_handler(btn,img)
{
 btn_mc1.btn._alpha = 100;
 // just some stuff to animate and enable the buttons that aren't current.
 for(x=1;x<11;x++) {
  TweenMax.to("btn_mc"+x, 0.5, {blurFilter:{blurX:0, blurY:0}});
  this["btn_mc"+x].btn.enabled = true;
 }

 btn.enabled = false;
 TweenMax.to(btn, 1, {blurFilter:{blurX:100, blurY:100}});

 loadImage(img);
}