簡體   English   中英

AS3錯誤中的按鈕移動控制

[英]Button Movement Control in AS3 Error

在actionscript 3.0中,我正在使用Adobe Air創建一個iOS應用。 對於主要玩家的動作,我使用按鈕。 每當我運行代碼時,都會出現錯誤。 代碼如下。

stop()
up_btn.addEventListener(MouseEvent.CLICK, fl_up);

function fl_up() {
        player.x += 5;
}

如果有人能告訴我這段代碼有什么問題,將不勝感激。

當您發布有關收到的錯誤的問題時,共享錯誤代碼/文本會最有幫助。 打開調試,您將確切知道代碼中斷的原因和位置。 也就是說,您忘記了在事件監聽器中保留參數。 我懷疑是罪魁禍首。

stop() // <- If this is the only frame on your document, you really don't need this.

up_btn.addEventListener(MouseEvent.CLICK, fl_up);

function fl_up(e:MouseEvent):void {
        player.x += 5;
}

暫無
暫無

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

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