# Add url to the MCs on the fly

**URL:** <https://forum.kirupa.com/t/add-url-to-the-mcs-on-the-fly/64545>\
**Category:** flash\
**Created:** [September 17, 2004, 12:15pm UTC](https://forum.kirupa.com/t/add-url-to-the-mcs-on-the-fly/64545 "2004-09-17T12:15:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![NovemberRain](https://avatars.discourse-cdn.com/v4/letter/n/73ab20/32.png) [@NovemberRain](https://forum.kirupa.com/u/NovemberRain)\
**Post date:** [September 17, 2004, 12:15pm UTC](https://forum.kirupa.com/t/add-url-to-the-mcs-on-the-fly/64545/1 "2004-09-17T12:15:20Z")

</div>

Is it possible add link to a duplicated movieclips dynamically?

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

```auto

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”

```auto
  
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");
 };
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 17, 2004, 1:34pm UTC](https://forum.kirupa.com/t/add-url-to-the-mcs-on-the-fly/64545/2 "2004-09-17T13:34:41Z")

</div>

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](http://www.kirupa.com)”, “\_blank”);  
};  
}

that will make them all open [kirupa.com](http://kirupa.com), but you had a trace so this probably isnt what your looking for,  
hope it helps,  
Ben

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 18, 2004, 8:42am UTC](https://forum.kirupa.com/t/add-url-to-the-mcs-on-the-fly/64545/3 "2004-09-18T08:42:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 18, 2004, 9:21am UTC](https://forum.kirupa.com/t/add-url-to-the-mcs-on-the-fly/64545/4 "2004-09-18T09:21:56Z")

</div>

> [@abhilashkk](#):
>
> Is it possible add link to a duplicated movieclips dynamically?
> 
> A movieclip named “box” on the stage and duplicated using the following code
> 
> ```auto
> 
> 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”
> 
> ```auto
>   
> 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");
> };
> }
> 
> ```

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”);  
};  
}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 18, 2004, 9:27am UTC](https://forum.kirupa.com/t/add-url-to-the-mcs-on-the-fly/64545/5 "2004-09-18T09:27:18Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 18, 2004, 9:29am UTC](https://forum.kirupa.com/t/add-url-to-the-mcs-on-the-fly/64545/6 "2004-09-18T09:29:59Z")

</div>

> [@abhilashkk](#):
>
> 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.
