Link to home
Create AccountLog in
Avatar of alrav79
alrav79

asked on

DuplicateMovie and Buttons...

Hey there guys. I am running a duplicate movie loop that is retrieving its information from an array that loaded an xml. The movies are duplicating fine, however, I am assigning each movie's button to get a certain url with onRelease. The problem is that the buttons are all loadaing the same url for some reason. Is this because they are all pointing to the same function?

for (i=0; i<shows.length; i++) {
            duplicateMovieClip(slot, "slot"+i, i);
            slot = eval("slot"+i);
            slot._y += x;
            
            //-------------------------------------
            //trace(slot);
            //---------------------------------------------
            slot.photoImage = shows[i].photoImage;
            slot.showTitle = shows[i].showTitle;
            slot.desc = shows[i].desc;
            slot.link = shows[i].link;

            slot.button.onRelease =  function()  { getUrl(slot.link); }            
            
            loadMovie(slot.photoImage, slot.cargathumb);                        
}
Avatar of alrav79
alrav79

ASKER

Nevermind guys. I finally got it. I just assigned the button its own variable, realizing i couldn't pass one into a dynamic function.
function printer() {
      slot._y = -x;

      for (i=0; i<shows.length; i++) {
            duplicateMovieClip(slot, "slot"+i, i);
            slot = eval("slot"+i);
            slot._y += x;
            
            //-------------------------------------
            //trace(slot);
            //---------------------------------------------
            slot.photoImage = shows[i].photoImage;
            slot.showTitle = shows[i].showTitle;
            slot.desc = shows[i].desc;
            slot.link = shows[i].link;
            
            slot.button.btnLink = slot.link;
            slot.button.onRelease = function() { trace(this.btnLink); }             
                                    
            loadMovie(slot.photoImage, slot.cargathumb);                        
      }
}
Avatar of Aneesh Chopra
here is the fixed CODE:
---------
for (i=0; i<shows.length; i++)
{
      duplicateMovieClip(slot, "slot"+i, i);
      slot = eval("slot"+i);
      slot._y += x;
      //-------------------------------------
      //trace(slot);
      //---------------------------------------------
      slot.photoImage = shows[i].photoImage;
      slot.showTitle = shows[i].showTitle;
      slot.desc = shows[i].desc;
      slot.link = shows[i].link;
      slot.button.onRelease = function()
      {
            getURL(this._parent.link);
      };
      loadMovie(slot.photoImage, slot.cargathumb);
}

---------

Rgds
Aneesh
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer