Copy link to clipboard
Copied
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?
The 1009 error indicates that one of the objects being targeted by your code is out of scope. This could mean that the object....
- is declared but not instantiated
- doesn't have an instance name (or the instance name is mispelled)
- does not exist in the frame where that code is trying to talk to it
- is animated into place but is not assigned instance names in every keyframe for it
- is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).
...Copy link to clipboard
Copied
if you are working with nested objects always use the click event over the mouse_down event, and event.currentTarget over event.target.
Copy link to clipboard
Copied
The 1009 error indicates that one of the objects being targeted by your code is out of scope. This could mean that the object....
- is declared but not instantiated
- doesn't have an instance name (or the instance name is mispelled)
- does not exist in the frame where that code is trying to talk to it
- is animated into place but is not assigned instance names in every keyframe for it
- is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).
If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.
And just in case it might be a misspelling... if this is a button wouldn't the naming more likely include "btn" rather than "bnt"
Find more inspiration, events, and resources on the new Adobe Community
Explore Now