Add url to the MCs on the fly

Is it possible add link to a duplicated movieclips dynamically?

A movieclip named “box” on the stage and duplicated using the following code


width = _root.box._x;
for (i=0; i<10; i++){
_root.box.duplicateMovieClip ("box" add i, i);
_root["box" add i]._x = width * i;
}

That is the root created the movieclips box1, box2 and sofar… How can we create different links to these mcs that are created on the fly?

I’ve also tried the following code but i’m getting the only link that “file10.html”

  
width = _root.box._x;
for (i=0; i<10; i++) {
 _root.box.duplicateMovieClip("box" add i, i);
 _root["box" add i]._x = width*i;
 _root["box" add i].onRelease = function() {
  getURL("file" add i add "." add "html");
  trace("file" add i add "." add "html");
 };
}


I really dont know if this is what your looking for but it may be so heres my 2 cents,

width = _root.box._x;
for (i=0; i<4; i++) {
_root.box.duplicateMovieClip(“box” add i, i);
_root[“box” add i]._x = width*i;
_root[“box” add i].onRelease = function() {
getURL(“http://www.kirupa.com”, “_blank”);
};
}

that will make them all open kirupa.com, but you had a trace so this probably isnt what your looking for,
hope it helps,
Ben

I’m sorry that this is not what exactly i mean. In the example you’ve given we can go to only one url of each button that are duplicated. I want to link each duplicated one to different webpages. Hope u can understand

width = _root.box._x;
for (i=0; i<10; i++) {
_root.box.duplicateMovieClip(“box” add i, i);
_root[“box” add i].ivar = i;
_root[“box” add i]._x = width*i;
_root[“box” add i].onRelease = function() {
trace(“file” add this.ivar add “.” add “html”);
};
}

My God, this time it’s working… thanks a lot

could u pls explan why u’ve used “this.ivar” and what does it mean?:book:

just a property we have created, you can call it anything you want.