attachMovie with variable name?

Hi,

does anyone know why this function is working fine (as long as I use the function only once - but the reason for that I get)


 
function CreateThumb(file,xp,yp,level)
{
 _root.attachMovie("img_holder","img_holder", level);
 img_holder._x = xp; 
 img_holder._y = yp; 
 img_holder.createEmptyMovieClip("img",1);
 img_holder.img.loadMovie(file);
 img_holder.onEnterFrame = function()
 {
  if(this.img.getBytesLoaded() >= this.img.getBytesTotal() && this.img.getBytesLoaded()>0) 
  {
   this.img._width = 15;
   this.img._height = 15;
   delete this.onEnterFrame;
  }
 }
}
 
CreateThumb("images/MAAT.JPG",100,100,1);

and why this one doesn’t - I simply used a variable for the attached movieclip


function CreateThumb(mcname, file,xp,yp,level)
{
 _root.attachMovie("img_holder",mcname, level);
 mcname._x = xp; 
 mcname._y = yp; 
 mcname.createEmptyMovieClip("img",1);
 mcname.img.loadMovie(file);
 mcname.onEnterFrame = function()
 {
  if(this.img.getBytesLoaded() >= this.img.getBytesTotal() && this.img.getBytesLoaded()>0) 
  {
   this.img._width = 15;
   this.img._height = 15;
   delete this.onEnterFrame;
  }
 }
}
 
CreateThumb2("newname", "images/MAAT.JPG",100,100,1);

I think the code itself is self-explanatory, so I won’t add any comments on that at this point.

It’s really irritating having a head full off design ideas and meeting problems like this one :smirk:

Thanks in advance.