Access of undefined property " " - actionscript-3

I am trying to make a skip button in Adobe Flash with Action Script 3.0, but when I go to test it I get the error:
gameMenu, Layer 'Actions', Frame 107, Line 4, Column 1 1120: Access of undefined property gamePlay.
I am not sure how to fix this, any help would be appreciated.
skip_btn.addEventListener(MouseEvent.CLICK,skipF);
function skipF(e:Event):void{
gotAndStop(105);
}

Can't find any errors. There are others like the ones in the comments other users have posted. If you're using Adobe Flash CC or CS4-6 permit debugging or launch your movies in debug mode using cntrl+shift+enter. You'll get the exact line of the error as well as any active variables that might be related to the issue.
skip_btn.addEventListener(MouseEvent.CLICK, skipF);
function skipF(e:MouseEvent):void
{
gotoAndStop(105);
}

Related

AS3 error- when trying to hit test object

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.

this.stage reference causes error in flash pro

My understanding was I could refer to a movie clip on the scene from AS via this.stage.movieclipname, but this keeps yielding the error:
Scene 1, Layer 'Actions', Frame 1, Line 18 1119: Access of possibly undefined property loader_obj through a reference with static type flash.display:Stage.
The loader_obj definitely has an instance name in the properties panel, and is a symbol in the library, so what causes this, and how should I reference it in AS3?
tried linking the object to actionscript, but that caused another error.
You should access root instead of this.stage when you are referring to pre-placed instances. This is considered bad practice, though. Like this:
MovieClip(root).loader_obj.x=0;
Linking an object to AS3 does a completely different thing: it creates a class with a provided name, so then you will be able to do var c=new LinkedClass() and receive an exact copy of a library movie clip or another kind of object.

Run-Time Errors Over Multiple Layers

I notice that when Flash warns me of run-time errors over multiple layers of script the line of error doesn't seem accurate (I'm pretty sure it just tells me what line of all the code the error is on, not the specific line of the layer I'm working with). The warning doesn't even tell me what layer the problem is on. For example:
TypeError: Error #1009: Cannot access a property or method of a null
object reference. at
_example_fla::MainTimeline/my_function()[_example_fla.MainTimeline::frame1:523]
Is there anyway I can get Flash to tell me what layer, frame and line (on that layer) the issue occurs?
No, unfortunately, Flash doesn't give this information about layers. You have to do a little math.
The error is occurring on Frame 1 (you can see that after the :: on the message.)
To find the layer, you have to count the lines of code on each layer, from the top down. Flash sees it all as one long block of code. Thus, FOR EXAMPLE, if layer 1 has 452 lines, layer 2 has 12, and layer 3 has 59, you can do the math and find your error on line 57 of that third layer.
523-452=71
71-12=59
Thus, line 57, layer 3
This can get annoying. It is for this reason that the standard practice at my company for code on the timeline is to put all code (except, usually, event listeners)on a layer by itself, at the top of the stack, called SCRIPTS. Nothing else lives in that layer - it is just empty with code. It makes life so much easier.

in what situation,gotoAndStop is not working

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.

How do i find which variable is undefined? (flash builder)

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