0
Error #1009: Cannot access a property or method of a null object reference.
at sto()[C:\Users\dani\Desktop\folder (2)\sto.as:11]
at runtime::ContentPlayer/loadInitialContent()
at runtime::ContentPlayer/playRawContent()
at runtime::ContentPlayer/playContent()
at runtime::AppRunner/run()
at ADLAppEntry/run()
at global/runtime::ADLEntry()

我用 flash as3 创建了一个按钮。你们能帮帮我吗

package  {

import flash.display.MovieClip;
import flash.events.MouseEvent;


public class sto extends MovieClip {


    public function sto() {

     start.addEventListener(MouseEvent.CLICK,kdown);//start is the instance name of a movieclip

            }
               function kdown(event:MouseEvent):void{
        nextFrame();
       }

}

}

我认为问题是 start.addEventListener(MouseEvent.CLICK,kdown); 但我不知道该怎么办

4

1 回答 1

0

错误消息确实具有意义以及有关错误发生位置的线索。

Error #1009: Cannot access a property or method of a null object reference.
at sto()[C:\Users\dani\Desktop\folder (2)\sto.as:11]

所以......被引用的东西是null ,错误发生在文件“sto.as”的第 11 行

正如几位评论者所指出的那样,这条线很可能

start.addEventListener(MouseEvent.CLICK,kdown);

所以start要么是未定义的,要么是未初始化的。那么是什么start?它在哪里声明和初始化?

嗯。。。好吧。看起来您只是想向实例添加一个事件侦听器。

利用:

  this.addEventListener(MouseEvent.CLICK,kdown);
于 2015-01-14T21:19:12.273 回答