Loading a MovieClip from my library!?

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!! :slight_smile:

-Dan :expressionless:

So what’s not working?

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

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

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

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

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

Is that what you’re doing ?

pom 0]

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

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) :

 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]

Ahhhhh!!! Too confusing!! I am not the greatest at actionscripting, so i don’t understand…

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

 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]

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.

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

-Dan :expressionless:

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++” ?

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

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.

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 :

 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]

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

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

pom 0]

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