attachMovie ? Please explain

Can someone please tell me about using attachMovie on a frame compared to using it on an object…such as attaching to a blank movieclip.
I am sure it has to do with using for certain situations, but I have not gotten far enough in my experience to know why and I would like to know.
:goatee: :-\

The attachmovie code itself is the same no matter how you use it, it all depends on where you use it when the code looks different.

If done on a frame, you need no handler, the code is executed when the frame is entered, in that case it looks like this…

_root.emptyMovieClipInstanceName.attachMovie("linkageName", "newName", level#);

If it were to be used on a button symbol, of course anything used on a button must be accompanied by an on handler for the process, something like…

on (release){
_root.emptyMovieClipInstanceName.attachMovie("linkageName", "newName", level#);
}

And if it is on a movie clip you will need to specify it in an onClipEvent handler (and you can use on handlers on movie clips in MX as well if you wanted to)

onClipEvent(load){
_root.emptyMovieClipInstanceName.attachMovie("linkageName", "newName", level#);
}

Oh yeah, and to get this to work you will need to right click on your clip you want attached in the library panel (CTRL+L) and choose “Linkage” then check the box for “Export for Actionscript”, then in the name box is where linkageName will be (name it whatever, but be sure to use that name in your script)

Thank you :sure:
I think I am starting to understand how these are different…just was wondering more of why is one better to use than another. With buttons the answer is obvious - because you want to clip to play on release (or on click, whatever) of the button.
It seems like attaching the clip to a frame or to another clip would be the same thing wouldn’t they?
(other than having to have a handler for attaching to another clip)
:cowboy:
:o Maybe I just need to give myself some more time to experiment and see for myself???

No, you are right, they pretty much are the same thing, it mostly depends on personal preference when using the code on a frame or on a movie clip.

I prefer frame, it is easier to locate when I need it because of that little “a” symbol on the frame.

But it sounds like you got it :slight_smile:

:cool: very good =)
thanks!!

No problem :cool: