簡體   English   中英

flash as3錯誤#1009:無法訪問空對象引用的屬性或方法

[英]flash as3 Error #1009: Cannot access a property or method of a null object reference

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); 但我不知道該怎么辦

錯誤消息確實具有含義以及關於錯誤發生位置的線索。

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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM