# Assigning movieclip to dynamically created movieclip

**URL:** <https://forum.kirupa.com/t/assigning-movieclip-to-dynamically-created-movieclip/204906>\
**Category:** Uncategorized\
**Created:** [October 24, 2006, 2:29pm UTC](https://forum.kirupa.com/t/assigning-movieclip-to-dynamically-created-movieclip/204906 "2006-10-24T14:29:05Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![sean1983uk](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@sean1983uk](https://forum.kirupa.com/u/sean1983uk)\
**Post date:** [October 24, 2006, 2:29pm UTC](https://forum.kirupa.com/t/assigning-movieclip-to-dynamically-created-movieclip/204906/1 "2006-10-24T14:29:05Z")

</div>

In part of my actionscript i’m using:

thumbnail\_mc.createEmptyMovieClip(“t”+k, thumbnail\_mc.getNextHighestDepth());

to create a seperate movieclips for ewach image in my xml file.

How would I then attach another movieclip to each of the newly created ones?

ie thumbnail\_mc.t0, thumbnail\_mc.t1, thumbnail\_mc.t2…

is there a way to do it automaticall7y or do i have to assign it to each one individually?

“thumbnail\_mc.t”+k.attachMovie obviously doesn’t work ☹

---

<div class="post-metadata">

**Author:** ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)\
**Post date:** [October 24, 2006, 3:31pm UTC](https://forum.kirupa.com/t/assigning-movieclip-to-dynamically-created-movieclip/204906/2 "2006-10-24T15:31:07Z")

</div>

[QUOTE=sean1983uk;1984362]In part of my actionscript i’m using:

thumbnail\_mc.createEmptyMovieClip(“t”+k, thumbnail\_mc.getNextHighestDepth());

to create a seperate movieclips for ewach image in my xml file.

How would I then attach another movieclip to each of the newly created ones?

ie thumbnail\_mc.t0, thumbnail\_mc.t1, thumbnail\_mc.t2…

is there a way to do it automaticall7y or do i have to assign it to each one individually?

“thumbnail\_mc.t”+k.attachMovie obviously doesn’t work :([/QUOTE]

```auto
thumbnail_mc["t"+k].attachMovie("mc", "mc", 1);

```

---

<div class="post-metadata">

**Author:** ![sean1983uk](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@sean1983uk](https://forum.kirupa.com/u/sean1983uk)\
**Post date:** [October 24, 2006, 4:05pm UTC](https://forum.kirupa.com/t/assigning-movieclip-to-dynamically-created-movieclip/204906/3 "2006-10-24T16:05:42Z")

</div>

Many Thanks for that!

tried it but its not working some how.

i got my code from this tutorial [http://www.kirupa.com/developer/mx2004/thumbnails.htm](http://www.kirupa.com/developer/mx2004/thumbnails.htm)

Basically trying to add the thumbnail title to each thumbnail which i’ve added in the xml file.

Not sure how to do that, thats why I thought i would have to attach another movie clip to the image and then try and retrive the relevant titles for each thumbnail.

Does this make sense?

---

<div class="post-metadata">

**Author:** ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)\
**Post date:** [October 24, 2006, 4:13pm UTC](https://forum.kirupa.com/t/assigning-movieclip-to-dynamically-created-movieclip/204906/4 "2006-10-24T16:13:51Z")

</div>

[QUOTE=sean1983uk;1984445]Many Thanks for that!

tried it but its not working some how.

[/QUOTE]

try a trace straight after the above code

```auto
trace(thumbnail_mc["t"+k].mc)

```

---

<div class="post-metadata">

**Author:** ![sean1983uk](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@sean1983uk](https://forum.kirupa.com/u/sean1983uk)\
**Post date:** [October 24, 2006, 4:27pm UTC](https://forum.kirupa.com/t/assigning-movieclip-to-dynamically-created-movieclip/204906/5 "2006-10-24T16:27:57Z")

</div>

its returns undefinded 5 times which is how many thumbnails there are. So guessing its attaching to it? but not staying there?

---

<div class="post-metadata">

**Author:** ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)\
**Post date:** [October 24, 2006, 4:28pm UTC](https://forum.kirupa.com/t/assigning-movieclip-to-dynamically-created-movieclip/204906/6 "2006-10-24T16:28:42Z")

</div>

this works ok-mc linkage id -ter

```auto
function thumbnails_fn(k) {
	thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());
	thumbnail_mc.createEmptyMovieClip("p"+k, thumbnail_mc.getNextHighestDepth());
	tlistener = new Object();
	tlistener.onLoadInit = function(target_mc) {
		target_mc._x = hit_left._x+(target_mc._width+5)*k;
		var clip = thumbnail_mc["p"+k].attachMovie("ter", "ter", 1000);
		clip._x = target_mc._x;
		target_mc.pictureValue = k;
		target_mc.onRelease = function() {
			p = this.pictureValue-1;
			nextImage();
		};
		target_mc.onRollOver = function() {
			this._alpha = 50;
			thumbNailScroller();
		};
		target_mc.onRollOut = function() {
			this._alpha = 100;
		};
	};
	image_mcl = new MovieClipLoader();
	image_mcl.addListener(tlistener);
	image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k);
}

```

---

<div class="post-metadata">

**Author:** ![sean1983uk](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@sean1983uk](https://forum.kirupa.com/u/sean1983uk)\
**Post date:** [October 24, 2006, 4:39pm UTC](https://forum.kirupa.com/t/assigning-movieclip-to-dynamically-created-movieclip/204906/7 "2006-10-24T16:39:19Z")

</div>

YOUR A STAR!!!

I’d hug you if you were here haha

Many Thanks!!

I’ll prob be asking another question later when i try and get the values across lol

---

<div class="post-metadata">

**Author:** ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)\
**Post date:** [October 24, 2006, 4:42pm UTC](https://forum.kirupa.com/t/assigning-movieclip-to-dynamically-created-movieclip/204906/8 "2006-10-24T16:42:21Z")

</div>

[QUOTE=sean1983uk;1984465]YOUR A STAR!!!

I’d hug you if you were here haha

Many Thanks!!

I’ll prob be asking another question later when i try and get the values across lol[/QUOTE]

No problem

---

<div class="post-metadata">

**Author:** ![sean1983uk](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@sean1983uk](https://forum.kirupa.com/u/sean1983uk)\
**Post date:** [October 24, 2006, 4:52pm UTC](https://forum.kirupa.com/t/assigning-movieclip-to-dynamically-created-movieclip/204906/9 "2006-10-24T16:52:25Z")

</div>

Hey again lol

Yeh that worked 🙂 and added the movieclip to the stage but is it creating an additional lot of movie clips twice? Also when i use

thumbnail\_mc[“p”+k].ter[“ter”+k].team.text = team[p]

its not getting any data from xml file for any of the clips?

guessing i’m referencing wrong somewhere?

---

<div class="post-metadata">

**Author:** ![sean1983uk](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@sean1983uk](https://forum.kirupa.com/u/sean1983uk)\
**Post date:** [October 24, 2006, 4:54pm UTC](https://forum.kirupa.com/t/assigning-movieclip-to-dynamically-created-movieclip/204906/10 "2006-10-24T16:54:23Z")

</div>

oooo got it!!!

just need to use

clip.team.text

YOUR A STAR

made my day!

---

<div class="post-metadata">

**Author:** ![sean1983uk](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@sean1983uk](https://forum.kirupa.com/u/sean1983uk)\
**Post date:** [October 24, 2006, 4:55pm UTC](https://forum.kirupa.com/t/assigning-movieclip-to-dynamically-created-movieclip/204906/11 "2006-10-24T16:55:30Z")

</div>

if you have a few minutes later could you explain the lines you added and why? so i dont have to use this blindly 🙂 think i get it but would be good to clarify 🙂

---

<div class="post-metadata">

**Author:** ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)\
**Post date:** [October 24, 2006, 6:18pm UTC](https://forum.kirupa.com/t/assigning-movieclip-to-dynamically-created-movieclip/204906/12 "2006-10-24T18:18:23Z")

</div>

[QUOTE=sean1983uk;1984478]if you have a few minutes later could you explain the lines you added and why? so i dont have to use this blindly 🙂 think i get it but would be good to clarify :)[/QUOTE]  
All we have done is created another clip to mimic the thumbnails.When you load into a clip -many properties are lost.  
your line

```auto
thumbnail_mc["p"+k].ter["ter"+k].team.text = team[p]

```

should have read

```auto
thumbnail_mc["p"+k].ter.team.text

```

but “clip” is shorter.
