View Full Version : attachMovie in Scrollpane

02-23-2006, 05:03 PM
I need to attach an MC from the library to the content in a scrollpane, but can't seem to figure out the right line of code to do it.

This works perfectly for creating an empty movie clip at _root and attaching the movie clip from the library:
var myButton = _root.createEmptyMovieClip("btnName", _root.getNextHighestDepth());
var myButton_mc = myButton.attachMovie("btnAdd", "btnAdd_mc", 0);

Now I need to do the same in a scrollpane. For a separate purpose in this scrollpane, I have successfully created an empty movie clip and loaded an external JPG using:
_root.scrollpane.content.createEmptyMovieClip("image1", _root.scrollpane.content.getNextHighestDepth());
_root.scrollpane.content["image1"]._x = 5;
_root.pipeMenuPane.content["image1"]._y = 5;
var imageMCLoader:MovieClipLoader = new MovieClipLoader();
imageMCLoader.loadClip("image.jpg", _root.scrollpane.content["image1"]);

So I thought this would work to create an empty movie clip in the scrollpane and attach a movie clip to it:
var BtnHld = _root.scrollpane.content.createEmptyMovieClip("btnName", _root.scrollpane.content.getNextHighestDepth());
var Btn_mc = BtnHld.attachMovie("btnAdd", "btnAdd_mc", 0);

Sadly, that doesn't work.... The create empty movie clip works and traces correctly, but tracing the Btn_mc for the attachMovie returns undefined, and the movie clip remains empty.

Since this works to attach to _root, and even to _root.scrollpane (which creates movie clips that don't move when the scrollpane is scrolled and float over its content), I'm baffled why I can't get this to work.



02-23-2006, 05:19 PM
Decided to get up from my desk for a few minutes for a much-needed break, and it occurred to me that attachMovie doesn't in any way clarify what library to look in, so it must be context sensitive. Had the thought that maybe it got that context based on where it was attaching the movie clip rather than from where it was called, which would mean the SWF in the scrollpane would need the image in its library in order to have any idea what "btnAdd" was.

I moved the button image to the FLA used in the scrollpane, republished its SWF and it worked.

Good reminder to take a break every now and then when things get confusing....