TypeError: Error #1009: When Communicating to a button within a MovieClip
I keep getting the following error:
[SWF] ProjectZ_iOS.swf - 12154544 bytes after decompression
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at ProjectZ_iOS_fla::MainTimeline/goButtons()[ProjectZ_iOS_fla.MainTimel ine::frame71:54]
Through trial and error, I've narrowed this issue down (line 54) to an 'if' statement (and all other statements) that comunicate to a button within a movie clip (PopUp_GetMore.bnt_MoreRemixesGoHome). When the user clicks this button I want to remove the movieclip from the stage and turn the visibility of the other buttons to true. I get this error for every statement that communicates to a button within the movieclip. I have several conditions within the function but for example sake, I'm only including the statement for one button below:
//Variables
var PopUp_GetMore:MainMoreRemixes_mc = new MainMoreRemixes_mc();
//******************************Stage buttons**************************************
stage.addEventListener(MouseEvent.MOUSE_DOWN, goButtons);
function goButtons(event:MouseEvent):void
{
//Adds the movieclip to the stage
if(event.target == bnt_GetMore)
{
addChild(PopUp_GetMore);
PopUp_GetMore.x = stage.stageWidth/2;
PopUp_GetMore.y = stage.stageHeight/2;
bnt_Behind.visible=false;
bnt_GetMore.visible=false;
bnt_Facts.visible=false;
bnt_AuthorIllustrator.visible=false;
}
//Removes the movie clip from the stage
if(event.target == PopUp_GetMore.bnt_MoreRemixesGoHome)
{
removeChild(PopUp_GetMore);
bnt_Behind.visible=true;
bnt_GetMore.visible=true;
bnt_Facts.visible=true;
bnt_AuthorIllustrator.visible=true;
}
}
What am I doing wrong? Should the statements that communcate with the buttons inside the movieclip be included in another function?
