actionscript 3.0 progress/complete for multiple audio

Is there a way to handle this sound loader where the onComplete is one function instead of 2? This way both sounds are loaded and then one onComplete is executed?

Also can the progress be combined so both sounds give back an overall progress on both?
a = new Sound();
			a.load(new URLRequest(mp3));
			b = new Sound();
			b.load(new URLRequest(mp3));
                        function onProgress(evt: ProgressEvent):void{
                        progVal = evt.bytesLoaded;
                        function onLoadComplete1(){
                        trace("sound 1 loaded");
                        function onLoadComplete2(){
                        trace("sound 2 loaded");

Open in new window

Who is Participating?
blue-genieConnect With a Mentor Commented:
hi, thinking out loud here.
in terms of combining the two.
you have two progress listeners.
so have each one call a method

something along these lines
//just for logic - code not tested.

function (firstVal, secondVal) {
var average:Number = (firstVal + secondVal)/2;
//base whatever display you're using on this average value;

then in terms of the complete listeners.

again, you could create a 3rd function which gets executed when both the others are done.
so set variables

var firstDone:Boolean = false;

then set it to true in the complete handler

if both are true call the third function.

lexshineAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.