ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller

Hi all,

I’m trying to modify a flex utility called photoNavigator. Basically all it does is that it loads a high res jpeg image and allows the user to magnify a portion of the image.

what im trying to do is allow the user to load different images. Obviously i try and remove the previous instance of photoNavgator and add a new instance (which contains the new file location as well). This is the simple code:


public function init():void
{
photo1 = new PhotoNavigator(‘pic1.jpg’);
addChild (photo1);
}

public function button9Handler(event:MouseEvent)
{
removeChild(photo1); // removes the previous instance of PhotoNavigator - works
photo2 = new PhotoNavigator(‘pic2.jpg’);
addChild(photo2);//trying to add a new instance of PhotoNavigator - doesnt work
}


this is the error message i get.

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at org.flepstudio::PhotoNavigator/setComplete()

please help!!!