2017-02-22 63 views
0

请帮助我,我真的很喜欢这个。错误#1009:无法访问空对象引用的属性或方法。 [太令人沮丧]

我只是无法找到问题所在。在框架1中一切正常,但当我点击下一个按钮时,出现错误。我已经检查过我使用的所有按钮的实例名称,并且所有的实例都被实例化了。我只是不知道我应该改变什么。暂停音乐2按钮已经存在。我也想知道为什么nextFrame();在frame1的第54行不起作用。

的错误

TypeError: Error #1009: Cannot access a property or method of a null object reference. 
at RECOVER_AGUILAREXERCISE_fla::MainTimeline/frame2()[RECOVER_AGUILAREXERCISE_fla.MainTimeline::frame2:21] 
at flash.display::Sprite/constructChildren() 
at flash.display::Sprite() 
at flash.display::MovieClip() 
at flash.display::Sprite/constructChildren() 
at flash.display::Sprite() 
at flash.display::MovieClip() 
at flash.display::Sprite/constructChildren() 
at flash.display::Sprite() 
at flash.display::MovieClip() 
at flash.display::Sprite/constructChildren() 
at flash.display::Sprite() 
at flash.display::MovieClip() 
at flash.display::Sprite/constructChildren() 
at flash.display::Sprite() 
at flash.display::MovieClip() 
at flash.display::Sprite/constructChildren() 
at flash.display::Sprite() 
at flash.display::MovieClip() 
at flash.display::MovieClip/nextFrame() 
at RECOVER_AGUILAREXERCISE_fla::MainTimeline/nextSoundTrack01()[RECOVER_AGUILAREXERCISE_fla.MainTimeline::frame1:54] 

代码框架2

stop(); 
album01.gotoAndPlay(49); 
title2.play(); 
import flash.media.SoundMixer; 
import flash.media.Sound; 

var sound02:Sound = new SITNight(); 
var soundChannel02:SoundChannel = new SoundChannel 
var soundLastPosition02: Number = 0; 


soundChannel02 = sound02.play(0); 


pauseMusic2.pauseBTN.addEventListener (MouseEvent.CLICK, pauseSoundTrack02); 

function pauseSoundTrack02 (e:MouseEvent): void { 
pauseMusic2.visible = false; 
soundLastPosition02 = soundChannel02.position; 
soundChannel02.stop(); 
} 



playMusic2.playBTN.addEventListener (MouseEvent.CLICK, playSoundTrack02); 

function playSoundTrack02 (e:MouseEvent): void { 
pauseMusic2.visible = true; 
soundChannel02 = sound02.play(soundLastPosition02); 
} 


stopMusic2.stopBTN.addEventListener (MouseEvent.CLICK, stopSoundTrack02); 

function stopSoundTrack02 (e:MouseEvent): void { 
pauseMusic2.visible = false; 
soundChannel02.stop(); 
soundLastPosition02 = 0; 
} 

nextMusic2.nextBTN.addEventListener (MouseEvent.CLICK, nextSoundTrack02) 

function nextSoundTrack02 (e:MouseEvent): void { 
pauseMusic2.visible = true; 
soundChannel02.stop(); 
soundLastPosition02 = 0; 
nextFrame(); 
} 

prevMusic2.prevBTN.addEventListener (MouseEvent.CLICK, prevSoundTrack02) 

function prevSoundTrack02 (e:MouseEvent): void { 
pauseMusic2.visible = true; 
soundChannel02.stop(); 
soundLastPosition02 = 0; 
gotoAndStop(1); 
} 

回答

0

你能找出哪一行是在帧2行21? 从我看到的,我认为问题是“soundChannel02”未被初始化。

可能是因为在var soundChannel02:SoundChannel = new SoundChannel中缺少“()”,如果没有错字。

相关问题