因此,继承人的代码: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