I am trying to test for the collision of two objects. Both are on the display list. They are movie clips, each containing a hit box. One is called hitboxx, and the other is called hits. However, when I test the following code:
if (character2.hitboxx.hitTestObject(Spike1.hits)||character2.hitboxx.hitTestObject(Spike2.hits)||character2.hitboxx.hitTestObject(Spike3.hits))
{
currLives--;
}
I get this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at SpikeJungle_fla::MainTimeline/frame1()[SpikeJungle_fla.MainTimeline::frame1:126]
it's difficult to say anything on the code. The code seems correct. May be you forget to add variable name or something. Or try to check one movie clip at a time. means try to remove the other condition in and check with one and see whether it's working. And also in Publish Settings >> Advanced >> permit Debugging check this option and compile again and you will get more about the errors.
Related
I would like to have many devices testing a game, and I find the best way to debug a game and solve specific code problems is to have the device connected and in debug mode in Adobe ANIMATE, that way I can catch any Errors in the Output window.
For Example, if I am debugging and connected to Animate, the output window will throw errors like :
ReferenceError: Error #1065: Variable bg_storage is not defined.
at global/flash.utils::getDefinitionByName()
at Game/stageAdd()[/Users/**/Game.as:360]
Now I know exactly what the problem is and where to find it. I love errors like this.
My question :
If I didn't have a device connected to Animate in Debugging mode, is there a way to make the game detect any errors thrown and store them as a String, that way I can put up a big text block on the game of the error string and keep track.
or at least a way to log them some how?
Ex :
If an error is thrown, have that error text set as a String variable, then have a text box write out that String variable.
I hope that isn't too confusing. If I am going about debugging in a poor way, I would love to know what you guys do to keep track of errors without being connected to debug mode.
EDIT
I can see an approach is you to add an uncaughtErrorEvent event to each function to be able to catch these errors...
loadbar.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR ... )
I am trying to make it so any error thrown in any part of the game will trace that error somewhere to a String value that I can call, so that I can see any error thrown during a play test session without being connected to debug mode.
Thanks!
Sure. There's a class intended exactly for that: https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/UncaughtErrorEvent.html See examples at the bottom of the page to listen to the right instances for that event.
You are also free go grab my own class that does the thing you want: https://bitbucket.org/thydmitry/ru.delimiter/src/2756fadd741a6d44276fde1701470daf24cebfa8/classes/ru/delimiter/utils/Log.as?at=default&fileviewer=file-view-default
You will need to add it to your project and then call in the main document class (in constructor, preferably):
Log.create(this);
Log.handleExceptions(this, true);
I have an existing source code. I have function called upload resource. If i click on upload button and try to upload image file it says following error.
jquery.fineuploader-3.4.1.min.js:4 [FineUploader] Caught exception in 'onComplete' callback - Cannot read property 'split' of null
In View file, Widget is added i.e. ext.EFineUploader.EFineUploader
Anyone have any idea what could be wrong?
The message indicates that there is an error in your onComplete callback function. You haven't posted your code, so there is no way to determine exactly where the error is, but it appears as if you are attempting to split a string, but the string in your code is null for some reason. You'll need to look closer at your code to determine where the error is.
I have 3 frames, I don't show the whole code, it's too huge.and the main code is
gotoAndStop(2);
trace('frame:',currentFrame)
the output should be frame: 2
But in fact it's frame: 1, and objects in frame 2 cannot be loaded and become null
no compiler errors
When I delete some codes after it, the application sometimes operate right and stops at frame 2.
This shouldn't happen as any code after it should not involve the output
although I can solve this when I delete the first frame,but it's quite risky to keep developing.
Any ideas why this happen?
Before keep going,I should mention I actually have compiler errors due to null objects,but it's not the main point.
And I have a class called host,the code gotoAndStop is also in the first place of constructor.
I have put override function in host, and the output is
stopping at frame: 2 Called from: Error
at host/gotoAndStop()
at host()
frame: 1
TypeError: Error #1009: Cannot access a property or method of a null object reference
at host()
Then I tried the method2 Creative Magic says,the result shows
stopping at frame: 2 Called from: Error
at host/gotoAndStop()
at host()
displaying frame: 1
frame: 1
TypeError: Error #1009: Cannot access a property or method of a null object reference
at host()
displaying frame: 2
This quite confuses me what's happening in the frame,I wonder the cause is like you say old version of SDK,thanks for help
Your problem can be either you've written buggy code or you use old Flash SDK.
In the first case you should check if you're calling gotoAndStop(), play() or gotoAndPlay() methods of your MovieClip. To do so you can edit the class of your MC:
In Flash Professional in the library panel right-click on the MC
Select "Edit Class"
In your selected IDE add following function
override public function gotoAndStop(frame:Object, scene:String = null):void
{
trace("stopping at frame:", frame, "Called from:", new Error().getStackTrace());
super(this).gotoAndStop(frame, scene);
}
It will trace when the gotoAndStop() method was called and who called it. It will let you see if the frame was set to frame by something else. I recommend you to override play() and gotoAndPlay() functions as well.
If you're intimidated by this code you could just add a trace() on each frame of your MC, since it's only 3 frames it shouldn't be too much work. Your trace could look something like that:
trace("displaying frame:", this.currentFrame);
The other possible cause could lie within the SDK you're using. I, myself had a strange bug when the loaded MC wouldn't listen to stop(), gotoAndStop() and other functions. The problem was solved by upgrading the SDK: http://www.adobe.com/devnet/flex/flex-sdk-download.html
The explanation on how to replace the old SDK is there as well.
I have been working in this error for days, i keep searching and asking for help, (including reading from this site as well). It is basically involved a lot of external actionscript.
Every time i finish the interactive and i want to go back to previous frame, the error goes:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at pizzaBaking/doRESTART()
and this is the doRESTART function
public function doRESTART(e:MouseEvent):void{
MovieClip(parent).gotoAndPlay(131);
MovieClip(parent).MENUS.visible = false;
MovieClip(parent).ABOUT.visible = false;
MovieClip(parent).VOUCHER.visible = false;
MovieClip(parent).UPDATES.visible = false;
Due to quite a few of file, i put it all in mediafire, in flash cs6 http://www.mediafire.com/download/10skpaizeyk2kul/pizzaHut.rar
thank you so much
1: Turn on Debugging
Go to your publish settings and enable "Permit Debugging". This will take your ambiguous error...
null object reference at pizzaBaking/doRESTART()
...to a much clearer...
null object reference at pizzaBaking/doRESTART() script\pizzaBaking.as:35
...which now denotes which line in your code to look for your issue.
2: Use the Debug Console
Use the debugging compile mode to bring up the Debug Console. This will provide you with an immediate look at the line of code in question, as well as the Call Stack, and the state of all available Variables. No programmer should be without one.
3: parent == null
When doRESTART() is being called, it no longer has a parent, ergo, when you call MovieClip(parent) it returns a null, and there is no MENUS property on null. This is why it's reporting null object reference.
If I were you, I'd seriously reconsider how you're approaching this. Remove all timeline code, and any use of frame animation. This is likely the reason why your pizzaBaking class lost its parent relationship. Also, there appear to be several instances in which you could consolidate repetitious code into a single function (KeyboardPizza.as being a prime example). Consider passing a method an argument to modify its behavior, or use switch case, or perhaps a lookup table.
That said, press on. It looks like you're making great progress on your project.
-Cheers
A flash application in flash builder is currently throwing this error:
ReferenceError: Error #1065: Variable
is not defined.
Not telling me which variable it is that's not defined, but note there are two spaces between 'variable' and 'is'. and it gives me some more feedback as to what lines of code are having trouble, but those lines are all within the actual flash/mxml packages and not any of the files in my own project.
I suspect it's related to my php data/services, but I don't see what variable would not be defined. I'm not very familiar with debugging, so I'm not sure how to determine with it where the problem is cropping up.
at global/flash.utils::getDefinitionByName()
at mx.utils::DescribeTypeCache$/describeType()[E:\dev\4.x\frameworks\projects\framework\src\mx\utils\DescribeTypeCache.as:106]
at com.adobe.serializers.utility::TypeUtility$/getType()[/Users/sameer/depot/flex/ide_builder/com.adobe.flexbuilder.dcrad/serializers/src/com/adobe/serializers/utility/TypeUtility.as:90]
at com.adobe.serializers.utility::TypeUtility$/assignProperty()[/Users/sameer/depot/flex/ide_builder/com.adobe.flexbuilder.dcrad/serializers/src/com/adobe/serializers/utility/TypeUtility.as:516]
at com.adobe.serializers.utility::TypeUtility$/convertToStrongType()[/Users/sameer/depot/flex/ide_builder/com.adobe.flexbuilder.dcrad/serializers/src/com/adobe/serializers/utility/TypeUtility.as:498]
at com.adobe.serializers.utility::TypeUtility$/convertListToStrongType()[/Users/sameer/depot/flex/ide_builder/com.adobe.flexbuilder.dcrad/serializers/src/com/adobe/serializers/utility/TypeUtility.as:454]
at com.adobe.serializers.utility::TypeUtility$/convertResultHandler()[/Users/sameer/depot/flex/ide_builder/com.adobe.flexbuilder.dcrad/serializers/src/com/adobe/serializers/utility/TypeUtility.as:367]
at mx.rpc.remoting::Operation/http://www.adobe.com/2006/flex/mx/internal::processResult()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\remoting\Operation.as:316]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:313]
at mx.rpc::Responder/result()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\Responder.as:56]
at mx.rpc::AsyncRequest/acknowledge()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:84]
at NetConnectionMessageResponder/resultHandler()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:547]
at mx.messaging::MessageResponder/result()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\MessageResponder.as:235]
look at line 106 for DescribeTypeCache.as There will likely be two variables, one of them is undefined