# Multiple Sound Errors + Spectrum

**URL:** <https://forum.kirupa.com/t/multiple-sound-errors-spectrum/313677>\
**Category:** flash\
**Created:** [September 7, 2010, 6:33am UTC](https://forum.kirupa.com/t/multiple-sound-errors-spectrum/313677 "2010-09-07T06:33:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![scissor\_mouth](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@scissor\_mouth](https://forum.kirupa.com/u/scissor_mouth)\
**Post date:** [September 7, 2010, 6:33am UTC](https://forum.kirupa.com/t/multiple-sound-errors-spectrum/313677/1 "2010-09-07T06:33:46Z")

</div>

hi everyone

I’m working on a project for varsity, I’ve created a music player but every time I publish it in Firefox i get multiple errors, (in IE it’s perfectly fine though) but otherwise it’s just not playing any music by default. I’ve read the other forums that cover these errors but I still don’t understand why I’m getting these:

[COLOR=Red]ArgumentError: Error #2068: Invalid sound.  
at flash.media::Sound/play()  
at index\_fla::MainTimeline/playSong()

Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error.  
at index\_fla::MainTimeline/nextSong()[/COLOR]

My current scripting for the mplayer:

[COLOR=RoyalBlue]var musicReq: URLRequest;  
var music:Sound = new Sound();  
var sndC:SoundChannel;  
var currentSnd:Sound = music;  
var currentIndex:Number = 0;  
var xml:XML;  
var songList:XMLList;  
var loader:URLLoader = new URLLoader();

currentSnd.addEventListener(IOErrorEvent.IO\_ERROR, soundIOErrorHandler);  
function soundIOErrorHandler(event:IOErrorEvent)

{  
//error suppression  
}

loader.addEventListener(Event.COMPLETE, Loaded);

loader.load(new URLRequest(“music/musiclist.xml”));

function Loaded(e:Event):void{  
xml = new XML(e.target.data);  
songList = xml.song;  
musicReq = new URLRequest(songList[0].url);  
music.load(musicReq);  
sndC = music.play();  
this.mplayer\_holder\_mc.mplayer\_mc.song\_txt.text = songList[0].title;  
this.mplayer\_holder\_mc.mplayer\_mc.artist\_txt.text = songList[0].artist;  
sndC.addEventListener(Event.SOUND\_COMPLETE, nextSong);  
}  
this.mplayer\_holder\_mc.mplayer\_mc.prev\_btn.addEventListener(MouseEvent.CLICK, prevSong);  
this.mplayer\_holder\_mc.mplayer\_mc.next\_btn.addEventListener(MouseEvent.CLICK, nextSong);  
this.mplayer\_holder\_mc.mplayer\_mc.play\_btn.addEventListener(MouseEvent.CLICK, playSong);  
this.mplayer\_holder\_mc.mplayer\_mc.stop\_btn.addEventListener(MouseEvent.CLICK, stopSong);

function prevSong(e:Event):void{  
if(currentIndex \> 0){  
currentIndex–;  
}  
else{  
currentIndex = songList.length() -1;  
}

```
var prevReq:URLRequest = new URLRequest(songList[currentIndex].url);
var prevPlay:Sound = new Sound(prevReq);
sndC.stop();
this.mplayer_holder_mc.mplayer_mc.song_txt.text = songList[currentIndex].title;
this.mplayer_holder_mc.mplayer_mc.artist_txt.text = songList[currentIndex].artist;
sndC = prevPlay.play();
currentSnd = prevPlay;
this.mplayer_holder_mc.mplayer_mc.play_btn.visible=false;
this.mplayer_holder_mc.mplayer_mc.stop_btn.visible=true;
sndC.addEventListener(Event.SOUND_COMPLETE, nextSong);

```

}

function nextSong(e:Event):void {  
if(currentIndex \< (songList.length() - 1)){  
currentIndex++;  
}  
else {  
currentIndex = 0;  
}

```
var nextReq:URLRequest = new URLRequest(songList[currentIndex].url);
var nextPlay:Sound = new Sound(nextReq);
sndC.stop();
this.mplayer_holder_mc.mplayer_mc.song_txt.text = songList[currentIndex].title;
this.mplayer_holder_mc.mplayer_mc.artist_txt.text = songList[currentIndex].artist;
sndC = nextPlay.play();
currentSnd = nextPlay;
this.mplayer_holder_mc.mplayer_mc.play_btn.visible=false;
this.mplayer_holder_mc.mplayer_mc.stop_btn.visible=true;
sndC.addEventListener(Event.SOUND_COMPLETE, nextSong);

```

}

function playSong(e:Event):void{  
sndC = currentSnd.play(0, int.MAX\_VALUE);  
this.mplayer\_holder\_mc.mplayer\_mc.play\_btn.visible=false;  
this.mplayer\_holder\_mc.mplayer\_mc.stop\_btn.visible=true;  
}

function stopSong(e:Event):void{  
sndC.stop();  
this.mplayer\_holder\_mc.mplayer\_mc.play\_btn.visible=true;  
this.mplayer\_holder\_mc.mplayer\_mc.stop\_btn.visible=false;  
}  
[/COLOR]  
Also for the spectrum I get this output error:

[COLOR=Red]TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at index\_fla::MainTimeline/spectrum()[/COLOR]

And the script:

[COLOR=RoyalBlue]stage.addEventListener(Event.ENTER\_FRAME, spectrum);  
function spectrum(Event):void {  
this.mplayer\_holder\_mc.mplayer\_mc.spectrum\_mc.leftSpec1\_mc.height = 20 \* sndC.leftPeak;  
…[it repeats the same function for a other movieClips]  
}[/COLOR]

My scripts are on separate layers to make coding easier to categorise but primarily they’re all in the same frame.

Any help is much appreciated.

Thank you :deranged:
