因此,繼承人的代碼:AS3空對象引用
function playSound():void
{
var channel:SoundChannel = sound.play();
channel.addEventListener(Event.SOUND_COMPLETE, onComplete);
}
function onComplete(event:Event):void
{
SoundChannel(event.target).removeEventListener(event.type, onComplete);
playSound();
}
我的錯誤上channel.addEventListener(Event.SOUND_COMPLETE, onComplete);
,但我不在一開始把它作爲一個遊戲運行一段時間沒有錯誤,因此Im提示在onComplete
函數或事件監聽器中存在問題,但是,我嘗試的所有嘗試都失敗了,現在我在這裏呆了一段時間。
我只是決定在這裏發佈,看看是否有人能看到問題。
在此先感謝!編輯: 對不起,我還沒有包括這個馬上。
錯誤:
TypeError: Error #1009: Cannot access a property or method of a null object reference. at projectSnowFlake_fla::MainTimeline/playSound()[projectSnowFlake_fla.MainTimeline::frame1:275] at projectSnowFlake_fla::MainTimeline/playGame()[projectSnowFlake_fla.MainTimeline::frame1:269] at projectSnowFlake_fla::MainTimeline/gameLoop()[projectSnowFlake_fla.MainTimeline::frame1:156] [UnloadSWF] projectSnowFlake.swf Test Movie terminated.
而且繼承人的sound
:
var sound:Sound = new MainSound();
'VAR渠道:的SoundChannel = sound.play();'你是什麼'sound'變量? –
你會得到什麼錯誤?我在想,你註冊事件的順序可能是一個問題。但是,不知道,除非我看錯誤。 – Zeus
看到最後編輯 – Dominiko