开发者

AS3---TypeError: Error #1009: Cannot access a property or method of a null object reference

Flash is giving me this error after I click a button to go to another frame. After I get the error, some buttons do not go to its destination and instead it just does nothin开发者_如何学JAVAg.

The error is as follows:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at wmhssports_fla::MainTimeline/frame39()

Here is the code for frame 39:

stop();

winter_btn.addEventListener(MouseEvent.CLICK, buttonClick1);
function buttonClick1(event:MouseEvent):void{
gotoAndPlay(39);
};

spring_btn_boys.addEventListener(MouseEvent.CLICK, buttonClick10);
function buttonClick10(event:MouseEvent):void{
gotoAndPlay(114);
};

fall_btn_boys.addEventListener(MouseEvent.CLICK, buttonClick11);
function buttonClick11(event:MouseEvent):void{
gotoAndPlay(135);
}; 


I took a look at your flash movie/application and the following is the solution to your problem:

AS3---TypeError: Error #1009: Cannot access a property or method of a null object reference

The above image is a screenshot of the timeline of your flash movie/application. It's at frame 39 that you recieve the error "TypeError: Error #1009: Cannot access a property or method of a null object reference. at wmhssports_fla::MainTimeline/frame39()". You recieve this because at that point the instance, spring_btn_girls, of your spring_btn button is null. To solve this give the instance of your spring_btn button the instance name "spring_btn_girls" on frame 34.


One of the buttons you're linking to either doesn't exist (typo of instance name?) or isn't on the frame you're coding on.

As John said, try trace(winter_btn, spring_btn, fall_btn);. The one that returns null is the one that you want to rectify.


You can actually set it up so it'll tell you what line of code is throwing the error. Here's a blog post I wrote on the subject: http://mykola.bilokonsky.net/2010/08/get-line-numbers-on-runtime-errors-in-flash/

Good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜