Problems with removeChild()

Greetings

I have a main movieclip called pageWork from which I am openeing another (in the future several) movieclip. This movieclip is galled galleryPhoto. This works fine.

However when I try to remove this movieclip I get this error:
TypeError: Error #1010: A term is undefined and has no properties.
at pageWork/frame1()

Here is the ActionScript in pageWork frame 1:

 
[LEFT]fred_mc.[COLOR=#000000]buttonMode[/COLOR] = [COLOR=#993300]true[/COLOR];
loop_mc.[COLOR=#000000]buttonMode[/COLOR] = [COLOR=#993300]true[/COLOR];
thump_mc.[COLOR=#000000]buttonMode[/COLOR] = [COLOR=#993300]true[/COLOR];
kmod_mc.[COLOR=#000000]buttonMode[/COLOR] = [COLOR=#993300]true[/COLOR];[/LEFT]
 
[LEFT][COLOR=#993300]var[/COLOR] photoGallery:galleryPhoto = [COLOR=#993300]new[/COLOR] galleryPhoto[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];[/LEFT]
 
[LEFT]fred_mc.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000000]ROLL_OVER[/COLOR], thumbOver[COLOR=#000000])[/COLOR];
fred_mc.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000000]ROLL_OUT[/COLOR], thumbOut[COLOR=#000000])[/COLOR];
fred_mc.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000000]CLICK[/COLOR], openPhoto[COLOR=#000000])[/COLOR];[/LEFT]
 
[LEFT]loop_mc.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000000]ROLL_OVER[/COLOR], thumbOver[COLOR=#000000])[/COLOR];
loop_mc.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000000]ROLL_OUT[/COLOR], thumbOut[COLOR=#000000])[/COLOR];[/LEFT]
 
[LEFT]thump_mc.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000000]ROLL_OVER[/COLOR], thumbOver[COLOR=#000000])[/COLOR];
thump_mc.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000000]ROLL_OUT[/COLOR], thumbOut[COLOR=#000000])[/COLOR];[/LEFT]
 
[LEFT]kmod_mc.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000000]ROLL_OVER[/COLOR], thumbOver[COLOR=#000000])[/COLOR];
kmod_mc.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000000]ROLL_OUT[/COLOR], thumbOut[COLOR=#000000])[/COLOR];[/LEFT]
 
[LEFT][COLOR=#993300]function[/COLOR] thumbOver[COLOR=#000000]([/COLOR][COLOR=#993300]e[/COLOR]:MouseEvent[COLOR=#000000])[/COLOR]:[COLOR=#993300]void[/COLOR]
[COLOR=#000000]{[/COLOR]
  [COLOR=#993300]e[/COLOR].[COLOR=#000000]currentTarget[/COLOR].[COLOR=#993300]gotoAndPlay[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]"over"[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR][/LEFT]
 
[LEFT][COLOR=#993300]function[/COLOR] thumbOut[COLOR=#000000]([/COLOR][COLOR=#993300]e[/COLOR]:MouseEvent[COLOR=#000000])[/COLOR]:[COLOR=#993300]void[/COLOR]
[COLOR=#000000]{[/COLOR] 
  [COLOR=#993300]e[/COLOR].[COLOR=#000000]currentTarget[/COLOR].[COLOR=#993300]gotoAndPlay[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]"out"[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR][/LEFT]
 
[LEFT][COLOR=#993300]function[/COLOR] openPhoto[COLOR=#000000]([/COLOR][COLOR=#993300]e[/COLOR]:MouseEvent[COLOR=#000000])[/COLOR]:[COLOR=#993300]void[/COLOR]
[COLOR=#000000]{[/COLOR]
 addChild[COLOR=#000000]([/COLOR]photoGallery[COLOR=#000000])[/COLOR];
 photoGallery.[COLOR=#000000]x[/COLOR] = -[COLOR=#000000]385[/COLOR];
 photoGallery.[COLOR=#000000]y[/COLOR] = -[COLOR=#000000]240[/COLOR];
 photoGallery.[COLOR=#993300]gotoAndPlay[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000]1[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR][/LEFT]
 
[LEFT]photoGallery.[COLOR=#000000]close_mc[/COLOR].[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000000]CLICK[/COLOR], closePhoto[COLOR=#000000])[/COLOR];
[COLOR=#f000f0]*//close_mc is the instance name for the close button within the photoGallery movieclip*[/COLOR][/LEFT]
 
[LEFT][COLOR=#993300]function[/COLOR] closePhoto[COLOR=#000000]([/COLOR][COLOR=#993300]e[/COLOR]:MouseEvent[COLOR=#000000])[/COLOR]:[COLOR=#993300]void[/COLOR]
[COLOR=#000000]{[/COLOR]
 removeChild[COLOR=#000000]([/COLOR]photoGallery[COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR][/LEFT]
 

I know that in the future I should remove the addEventListener also, but I really just want to get this part working. I’m really confused as to why it isn’t.

p.s. I’ve also tried this.removeChild(photoGallery); with similar results.