# Loading a MovieClip from my library!?

**URL:** <https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596>\
**Category:** flash\
**Created:** [May 21, 2002, 8:15pm UTC](https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596 "2002-05-21T20:15:45Z")\
**Posts on this page:** 19\
**Page:** 1

<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:** [May 21, 2002, 8:15pm UTC](https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596/1 "2002-05-21T20:15:45Z")

</div>

Hey, I got a huge problem. I am basing my site layout all one this one actionscript thingy…when you press a button, a window pops up. The window is from the library. It’s called “ContactWindow” and its linkage is “contact”. I have been tearing my hair out trying to figure this out, but I can’t seem to get this one!! Someone help!!

**Using Flash MX**

Thanks a lot!! 🙂

-Dan 😑

---

<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:** [May 21, 2002, 8:27pm UTC](https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596/2 "2002-05-21T20:27:53Z")

</div>

So what’s not working?

---

<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:** [May 21, 2002, 8:37pm UTC](https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596/3 "2002-05-21T20:37:30Z")

</div>

When I press the button, nothing happens!! :lol:

---

<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:** [May 21, 2002, 8:41pm UTC](https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596/4 "2002-05-21T20:41:18Z")

</div>

do a test movie, hit the button, then do a “view objects” has the object appeared in that list or not?

---

<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:** [May 21, 2002, 8:49pm UTC](https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596/5 "2002-05-21T20:49:09Z")

</div>

on (release) {  
MovieClip.attachMovie(contact,Contactwindow);  
}

There’s the script…i just know that something is missing ☹

---

<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:** [May 21, 2002, 8:51pm UTC](https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596/6 "2002-05-21T20:51:41Z")

</div>

```auto
 this.attachMovie("contact", "t"+i, i);

```

Is that what you’re doing ?

pom 0]

---

<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:** [May 21, 2002, 8:52pm UTC](https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596/7 "2002-05-21T20:52:54Z")

</div>

What the heck is the “t”+i, i ? Where did that come from?

Still isn’t working!!! Someone send me your AIM sn, so we can talk it out over instant messaging…that would be nicer

---

<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:** [May 21, 2002, 8:57pm UTC](https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596/8 "2002-05-21T20:57:28Z")

</div>

I don’t have it.  
“t”+1 is the name of the clip when it’s attached. Actually, that was part of this code (it goes to an empty clip) :

```auto
 onClipEvent (load) {
&nbsp &nbsp &nbsp &nbsp i = 0 ;
&nbsp &nbsp &nbsp &nbsp function trinity () {
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp i++;
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp attachMovie("agent", "t"+i, i);
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp var mc = this["t"+i];
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp mc._x = _xmouse;
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp mc._y = _ymouse;
&nbsp &nbsp &nbsp &nbsp }
}
onClipEvent (mouseDown) {
&nbsp &nbsp &nbsp &nbsp pressing = 1;
}
onClipEvent (mouseUp) {
&nbsp &nbsp &nbsp &nbsp pressing = 0;
}
onClipEvent (enterFrame) {
&nbsp &nbsp &nbsp &nbsp if (pressing) {
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp trinity();
&nbsp &nbsp &nbsp &nbsp }
}

```

pom 0]

---

<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:** [May 21, 2002, 8:59pm UTC](https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596/9 "2002-05-21T20:59:41Z")

</div>

Ahhhhh!!! Too confusing!! I am not the greatest at actionscripting, so i don’t 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:** [May 21, 2002, 9:29pm UTC](https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596/10 "2002-05-21T21:29:10Z")

</div>

Are you sure you want to attach movie ?  
If so, you need a button with the code :

```auto
 on (press) {
    i++;
    _root.attachMovie("contact", "t"+i, i);
    var mc = _root["t"+i];
    mc._x = Math.round(Math.random()*500);
    mc._y = Math.round(Math.random()*400);
}

```

Still not good ?

pom 0]

---

<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:** [May 21, 2002, 10:10pm UTC](https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596/11 "2002-05-21T22:10:36Z")

</div>

as long as you’ve got the linkage set, it should work fine dan. The code problem that I see is this.

on (release) {  
MovieClip.attachMovie(contact,Contactwindow);  
}

in this example, what is “MovieClip”? It should be an instance name of a movie clip that you’re attaching this too, or it should be “\_root”

like this

on (release) {  
\_root.attachMovie(“contact”,“newName”,aDepthNumberHere);  
}

where “contact” is the name of the movie in the linkage dialogue box, and “newName” is the instance name of the attached movie.

---

<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:** [May 21, 2002, 11:48pm UTC](https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596/12 "2002-05-21T23:48:47Z")

</div>

Thanks you guys!!! I don’t know what I would do without you! 🙂 I still gotta test it out though…Thanks a bunch!

-Dan 😑

---

<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:** [May 22, 2002, 9:30am UTC](https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596/13 "2002-05-22T09:30:18Z")

</div>

Pom, thanks for that code!! But I only want one to pop up, because if I push it again, another window pops up!! I don’t want that to happen, do I just have to remove the ++ in the “i++” ?

---

<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:** [May 22, 2002, 12:24pm UTC](https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596/14 "2002-05-22T12:24:27Z")

</div>

on (press) {  
\_root.attachMovie(“contact”, “t1”, 1);  
var mc = \_root.t1;  
mc.\_x = Math.round(Math.random()\*500);  
mc.\_y = Math.round(Math.random()\*400);  
}

---

<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:** [May 23, 2002, 4:09am UTC](https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596/15 "2002-05-23T04:09:38Z")

</div>

Well… this one will actually keep doing the effect every time you press the button, but you probebly wont notice that a new movie clip is being attached at the same level, with the same content, and deleting the previous mc at that level.

---

<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:** [May 24, 2002, 5:26am UTC](https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596/16 "2002-05-24T05:26:14Z")

</div>

The only trouble Upu is that the movie is placed randomly in that code, so you’ll notice the attachment. Dan, You can use the usual trick :

```auto
 on (press) {
if (clicked) {
  clicked = !clicked ;
  _root.attachMovie("contact", "t1", 1);
  var mc = _root.t1;
  mc._x = Math.round(Math.random()*500);
  mc._y = Math.round(Math.random()*400);
  }
}

```

pom 0]

---

<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:** [May 24, 2002, 5:51am UTC](https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596/17 "2002-05-24T05:51:43Z")

</div>

I dont’ see why it needs to be random in there at all. You can just set the x and y to whatver you like. Or even keep track of an array of locations so that the windows always popped up in a particular place, but not necessarly the same place.

ultimately all you need is

on (press) {  
\_root.attachMovie(“contact”, “t1”, 1);  
}

---

<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:** [May 25, 2002, 1:01pm UTC](https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596/18 "2002-05-25T13:01:50Z")

</div>

Yeah yeah yeah, but as there was random in your code, I just thought I’d say… Anyway.

pom 0]

---

<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:** [May 30, 2002, 4:00am UTC](https://forum.kirupa.com/t/loading-a-movieclip-from-my-library/2596/19 "2002-05-30T04:00:59Z")

</div>

sorry… I downplayed your discovery of my error. My ego was showing again. 😉
