Loading movieclip - really basic question

Hi
I know how to do a load movie action when i am calling a movie externaly, but how do i go about loading a movie clip that is already in the library.
I have never done this before. What I have done is had the movie clip sitting on the stage with an empty frame in frame 1 and on an event you go to frame 2.
There must be a better way

Thanking you
Miffy :slight_smile:

Calling from a library…hmmmm. Oh yeah, I know how to do that. First what I need you to do is open your library and right click on the object you want attached in the library. Click on Linkage and check the Export for Actionscript checkbox.

Under Identifier, put any name you want (in my example I called it clipToAttach). Hit OK.

Create a movie clip on the stage that you want your library clip to attach to. On the movie clip add this code…


onClipEvent (load) {
	_this.attachMovie("clipToAttach", "clipToAttach2", 2);
}

clipToAttach = just that
clipToAttach2 = the required rename, you can make this whatever you want.
2 = depth of the clip

I hope this helps, any questions, just ask:)

Can I use the
onClipEvent (load)
action for a button or would it be
on release??
The button is what would prompt the movieclip to open

I hope you understand my question

Thanks for your help
Cheers
:slight_smile:

You actually can’t attach to a button, only to another movie clip. BUT… If you have your button in a movie clip, that saves the day.

What I did was made a button instance. Then added the actions to my button, then made the button a movie clip instance and used this code


on(release) {
	_root.clipAttacher.attachMovie("clipToAttach", "clipToAttach2", 2);
}


clipAttacher = clip you want your library clip to attach to(clip that contains your button)

Now I see your using MX, which is what I use, and you don’t have to use a button at all. These are called Dynamic Event Handlers. What you do with this is…draw your button and make it a movie clip instead of a button instance. NO BUTTONS HERE!

Now after you drew up your clip, click on the FRAME and open the actions panel. Add these actions…


_root.clipAttacher.onPress = function() {
	this.attachMovie("attachClip", "attachClip1", 2);
};

After you add that code to the frame test out your movie. Press your “button” and see what happens.

I hope this helps and wasn’t too confusing. If it was just let me know what part you were confused about and I will try and clarify.

on(release) {
_parent.attachMovie(“clipToAttach”, “clipToAttach2”, 2);
}

I think that this will work as well.

just thought I would mention it because _parent is preferable in almost every situtation to _root as a locator.
i. e. if ten days down the road you opt to move the movie clip to another level, the parent identifier will still work, where as with the other method you’ll have to go in and edit the addressing.

I hope I didnt’ add confusion to this… just trying to be helpful. :slight_smile:

You didn’t confuse me. You actually cleared something up for me. I never knew the difference between _root and _parent. I never actually felt the need to use _parent for any reason so I never read up on it. Now that I know what it does, I think I will use it more often.

Thanks david.

Once you go to your parent, you’ll never go back to your roots. :stuck_out_tongue:

really… I rarely if ever use the _root identifier. I’m always ending up loading things into other clips… when everything is made separately, and put together at run time you’ll know right away why _parent RULES!!

:slight_smile: Glad I could teach ya something lostinbeta… you’re such a smartypants already.

_parent is tricky though. If you have problems with the addressing, let me know and I’ll walk you through whatever I can.

Thanks david. I will test out that _parent thing when I get back from vacation. Leaving Friday and coming back Monday:)

I may be a smartypants already, but I still have A LOT to learn.