# Preloader Problems w/ Photo Gallery

**URL:** <https://forum.kirupa.com/t/preloader-problems-w-photo-gallery/275097>\
**Category:** flash\
**Created:** [November 9, 2008, 8:29pm UTC](https://forum.kirupa.com/t/preloader-problems-w-photo-gallery/275097 "2008-11-09T20:29:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![txnyriny](https://avatars.discourse-cdn.com/v4/letter/t/838e76/32.png) [@txnyriny](https://forum.kirupa.com/u/txnyriny)\
**Post date:** [November 9, 2008, 8:29pm UTC](https://forum.kirupa.com/t/preloader-problems-w-photo-gallery/275097/1 "2008-11-09T20:29:16Z")

</div>

Hi:

I’m building a photo gallery with the following code being a sample for each image. Unwieldy, I know. My preloader (just the component preloader in Flash) is called my\_pb. Dancers is the name of the thumbnail/button, and MC is a movie clip that contains myLoader.

The code works, except that when I change pages and bring up a photo, I get an error that says: Error #2025: The supplied DisplayObject must be a child of the caller.  
at flash.display:: DisplayObjectContainer/removeChild()

I don’t get this when I just move around between various photos on the same page. I even tried introducing a different preloader for each page, but that didn’t change anything.

I’d really appreciate any help on this. Thanks a lot!

dancers.addEventListener (MouseEvent.CLICK, peldr1a)  
function peldr1a(e:Event) {  
myLoader.load(new URLRequest(“pictures/Performance/pink dancers.jpg”));  
addChild(my\_pb);  
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler\_dancers);  
MC.addChild(myLoader);  
}  
function completeHandler\_dancers(event:Event):void {  
TransitionManager.start(event.target.loader.parent , {type:Fade, direction:Transition.IN, duration:1, easing:Strong.easeOut});  
removeChild(my\_pb);  
}
