PDA

View Full Version : Loading a MovieClip from my library!?



dansflash2001
May 21st, 2002, 04:15 PM
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 :|

upuaut8
May 21st, 2002, 04:27 PM
So what's not working?

dansflash2001
May 21st, 2002, 04:37 PM
When I press the button, nothing happens!! :lol:

upuaut8
May 21st, 2002, 04:41 PM
do a test movie, hit the button, then do a "view objects" has the object appeared in that list or not?

dansflash2001
May 21st, 2002, 04:49 PM
on (release) {
MovieClip.attachMovie(contact,Contactwindow);
}

There's the script...i just know that something is missing :(

ilyaslamasse
May 21st, 2002, 04:51 PM
this.attachMovie("contact", "t"+i, i);Is that what you're doing ?

pom 0]

dansflash2001
May 21st, 2002, 04:52 PM
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

ilyaslamasse
May 21st, 2002, 04:57 PM
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]

dansflash2001
May 21st, 2002, 04:59 PM
Ahhhhh!!!! Too confusing!! I am not the greatest at actionscripting, so i don't understand....

ilyaslamasse
May 21st, 2002, 05:29 PM
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]

upuaut8
May 21st, 2002, 06:10 PM
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.

dansflash2001
May 21st, 2002, 07:48 PM
Thanks you guys!!! I don't know what I would do without you! :) I still gotta test it out though...Thanks a bunch!

-Dan :|

dansflash2001
May 22nd, 2002, 05:30 AM
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++" ?

upuaut8
May 22nd, 2002, 08:24 AM
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);
}

upuaut8
May 23rd, 2002, 12:09 AM
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.

ilyaslamasse
May 24th, 2002, 01:26 AM
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]

upuaut8
May 24th, 2002, 01:51 AM
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);
}

ilyaslamasse
May 25th, 2002, 09:01 AM
Yeah yeah yeah, but as there was random in your code, I just thought I'd say... Anyway.

pom 0]

upuaut8
May 30th, 2002, 12:00 AM
sorry.. I downplayed your discovery of my error. My ego was showing again. ;)