[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1469
  • Last Modified:

Null Object Reference: Flash CS4 AS 3.0

I'm getting some errors:
I read the following post but couldn't figure out how to apply it to my situation:

http://www.experts-exchange.com/Software/Photos_Graphics/Web_Graphics/Macromedia_Flash/ActionScript/Q_24061743.html?sfQueryTermInfo=1+10+flash+null+object+refer
TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at 11MockupsAll_ha_interactive4_fla::MainTimeline/frame2()
	at flash.display::MovieClip/gotoAndStop()
	at 11MockupsAll_ha_interactive4_fla::MainTimeline/clickLogIn()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at 11MockupsAll_ha_interactive4_fla::MainTimeline/clickLogIn()

Open in new window

0
markerline
Asked:
markerline
  • 8
  • 6
1 Solution
 
ChristoferDutzCommented:
Well in order to help you here, you certainly have to post a little more information.
IN general you are propably using a variable, that is "null", because it has not been initialized by setting it's value to anything or by creating a new instance with "new Blah();"
0
 
markerlineAuthor Commented:
I tried to use the debugger to see where the null references were.  I saw a lot of them when I looked in the variable tab under "this" and clicked the plus-sign.  However, then my Flash Player session froze so I could no longer debug the movie.

How do I post extra information?  Should I post the file itself?  It's Flash CS4, ActionScript 3.0 .

Thanks,
markerline
0
 
rascalpantsCommented:
well from the "limited" posting information, it looks like you have... as ChristoferDutz has said, a non-existing reference to either a variable or property...  that is located on Frame 2 in your main timeline.

rp / Zone Advisor
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
markerlineAuthor Commented:
Well, that's apparent from the error codes.  I also have a null reference for the "clickLogIn()" function that is being called.  But the detail in the debugger doesn't tell me enough for me to be able to get rid of the call.  

What I'm really saying is that I don't understand ActionScript 3.0 where timeline calls are made without the use of onClipEvent() calls (for example), or onEnterFrame() calls.  AS 2.0 was more simple in this respect.  So how can I fix the portion on frame 2.  I have code split across several layers--I can't seem to narrow down the root of the problem.  In tutorials that I've seen in books, all the actionscript happens on frame 1 of the movie and spans the length of the movie.  But I had to split my actions across frames and across layers to isolate function calls to frames that contain the button or movie clip.  Given that, I don't see how I could have null calls but again, I can't read or code AS 3.0 very well.

Any help is greatly appreciated.

-markerline
0
 
rascalpantsCommented:
Its only apparent if one assumes the person asking knows how to read the error codes...  as for me...  I hate to assume.

well, normally AS 3.0 project are programmed in a way, that almost every bit of code is seperate form visual elements on in the IDE (Flash software).  Then classes are used to do the fun stuff...

can you post the code for all layers (seperated please) in frame 2?

but without looking... and assuming...  most likely your issue is that your layers with your functions do not span all of the way to the proper spots...   if not, start tracing out properties and such and see if they are undefined.

rp / ZA
0
 
markerlineAuthor Commented:
Okay, it's a long bit of code.  Three layers identified as ---frame:---layername:2---
---frame:---logname_text:2---
 
uName=userName.text;
logName.text = uName;
 
================
 
 
---frame:---actions_main:2---
 
stop();
//import fl.controls.Button;
 
var searchMC:search_mc = new search_mc();
btnGo.addEventListener(MouseEvent.CLICK,clickGo);
function clickGo(evt:MouseEvent){
	addChild(searchMC);
	searchMC.x=200;
	searchMC.y=200;
	searchMC.dynText.text=inpSearch.text;
}
 
var addMC:add_mc = new add_mc();
 
searchMC.closeBox1.addEventListener(MouseEvent.CLICK,closeSearch);
function closeSearch(evt:MouseEvent){
	removeChild(searchMC);
}
addMC.closeBox2.addEventListener(MouseEvent.CLICK,closePopUp);
function closePopUp(evt:MouseEvent){
	removeChild(addMC);
}
btnHOME_NavT.addEventListener(MouseEvent.CLICK,clickHOME);
function clickHOME(evt:MouseEvent){
	gotoAndStop("homepage");
}
 
btnABOUT_NavT.addEventListener(MouseEvent.CLICK,clickABOUT);
function clickABOUT(evt:MouseEvent){
	gotoAndStop("about");
}
 
btnHELP_NavT.addEventListener(MouseEvent.CLICK,clickHELP);
function clickHELP(evt:MouseEvent){
	gotoAndStop("help1");
}
 
btnFAQ.addEventListener(MouseEvent.CLICK,clickFAQ);
function clickFAQ(evt:MouseEvent){
	gotoAndStop("help1");
}
 
btnAddContacts.addEventListener(MouseEvent.CLICK,clickAddContact);
function clickAddContact(evt:MouseEvent){
	//removeChild(addMC);
	addChild(addMC);
	addMC.x=100;
	addMC.y=300;
//	gotoAndStop("addContact");
}
btnAddContactsNav.addEventListener(MouseEvent.CLICK,clickAddContactNav);
function clickAddContactNav(evt:MouseEvent){
	//removeChild(addMC);
	addChild(addMC);
	addMC.x=100;
	addMC.y=300;
//	gotoAndStop("addContact");
}
addMC.addContactPopUp.addEventListener(MouseEvent.CLICK,clickAddPopUp);
function clickAddPopUp(evt:MouseEvent){
	gotoAndStop("addContact");
}
addMC.importPopUp.addEventListener(MouseEvent.CLICK,clickImportPopUp);
function clickImportPopUp(evt:MouseEvent){
	gotoAndStop("importContact");
}
btnViewContacts.addEventListener(MouseEvent.CLICK,clickViewContact);
function clickViewContact(evt:MouseEvent){
	gotoAndStop("viewContacts");
}
btnViewContactsNav.addEventListener(MouseEvent.CLICK,clickViewContactNav);
function clickViewContactNav(evt:MouseEvent){
	gotoAndStop("viewContacts");
}
 
btnDeleteContacts.addEventListener(MouseEvent.CLICK,clickDeleteContact);
function clickDeleteContact(evt:MouseEvent){
	gotoAndStop("deleteContact");
}
btnDeleteContactsNav.addEventListener(MouseEvent.CLICK,clickDeleteContactNav);
function clickDeleteContactNav(evt:MouseEvent){
	gotoAndStop("deleteContact");
}
 
btnExportContacts.addEventListener(MouseEvent.CLICK,clickExport);
function clickExport(evt:MouseEvent){
	gotoAndStop("exportContact");
}
btnParentLog.addEventListener(MouseEvent.CLICK,clickParentLog);
function clickParentLog(evt:MouseEvent){
	gotoAndStop("parentLog");
}
 
btnExportContactsNav.addEventListener(MouseEvent.CLICK,clickExportNav);
function clickExportNav(evt:MouseEvent){
	gotoAndStop("exportContact");
}
 
btnParentLogNav.addEventListener(MouseEvent.CLICK,clickParentLogNav);
function clickParentLogNav(evt:MouseEvent){
	gotoAndStop("parentLog");
}
 
 
 
 
============================
 
---frame:---logout:2---
 
btnLogOut.addEventListener(MouseEvent.CLICK,clickLogOut);
function clickLogOut(evt:MouseEvent):void{
	gotoAndStop("regisThanks");
}

Open in new window

0
 
rascalpantsCommented:

you reference a few custom classes...  can you make sure that each of those classes has all of the references that are needed....

I also don't see any place where you are importing your classes for  these custom classes.  they need to be on each frame that is referencing a new instance of the class...  this is why framecode is BAD :)


Also, when you run the Debug in the IDE, you should get a line number in the code...

try doing a control + shift + enter and see what happens...

also, where do you instantiate uName and logName?  I don't see that anywhere... (meaning var uName:String )



otherwise, unless you misspelled a reference somewhere, that I didn't see, I don't see the null reference.

rp / ZA


0
 
markerlineAuthor Commented:
I instantiated the uName on Layer23 frame 1.  logName.text shouldn't get instantiated because logName is the instance of a textInput component on the stage itself.  Unless I'm misunderstanding the concept, which could be.  (userName.text is also a property of a textInput component instance on the stage).

Also, when I try to debug the movie the debugger freezes which means I can't properly see where the errors are.  Do I not have enough memory?  Am I supposed to be using a 64-bit Mac instead of 32-bit Windows to run this application?

Thanks,
markerline
var uName:String = userName.text;

Open in new window

0
 
rascalpantsCommented:
ahhh....  det (GOD) ails.

yeah, you can reference it that way, I just was not sure what each of those were...

You should be able to run the software on either system.. I am currently on 32-bit windows XP Pro...

can you compile this normally, without errors?  if not, then you have an infinite loop in your programming... typically in a for statement or or interval or seomthing...

rp / ZA

0
 
markerlineAuthor Commented:
I can compile the program.  I'm not sure what's wrong with the debugger.  It debugs the first frame but when I click on other frames it freezes.  I can't compile without errors.  That is, it compiles and gives me an error once I start to interact with the movie.  It doesn't throw errors on the first frame, though.

-markerline
0
 
rascalpantsCommented:
Well then u will have to do this the hard way then, and create a "trace trail"... end when you compile, u look where the last trace that gets output is located.

It sucks, but it might be ur only way

 rp / ZA
0
 
markerlineAuthor Commented:
I don't get a trace result for the following code on layer:logname_text:frame2
=============================
uName=userName.text;
logName.text = uName;
trace(uName+"logname_text_lyr:2");
=============================
I think this might be a culprit, although I will continue to try tracing other action layers.  The problem is that you can't trace events on every frame as the movie plays with the old function onClipEvent(enterFrame) (also coded as onEnterFrame=function(){ blah })

-markerline
0
 
rascalpantsCommented:
do u get anything for userName  the textfield?

rp / ZA
0
 
markerlineAuthor Commented:
userName.text is an input field.  uName is supposed to reflect that and be assigned to logName.text (dynamic text field) but in frame 2 where logName exists, I don't get anything (and my text isn't white on white either).  Not sure what's going on.

-markerline
0
 
markerlineAuthor Commented:
I fixed the uName issue.  I had referenced it and assigned it in an incorrect order.  Now that that is working and I'm reflecting the userName.text on frame 2, how do I deal with the other null references?

-markerline
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 8
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now