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));
			a.addEventListener(ProgressEvent.PROGRESS,onProgress,false,0,true);
			a.addEventListener(Event.COMPLETE,onLoadComplete1,false,0,true);
 
			b = new Sound();
			b.load(new URLRequest(mp3));
			b.addEventListener(ProgressEvent.PROGRESS,onProgress,false,0,true);
			b.addEventListener(Event.COMPLETE,onLoadComplete2,false,0,true);
 
                        function onProgress(evt: ProgressEvent):void{
                        progVal = evt.bytesLoaded;
 
                          }
 
                        function onLoadComplete1(){
                        trace("sound 1 loaded");
                        }
 
 
                        function onLoadComplete2(){
                        trace("sound 2 loaded");
                        }

Open in new window

lexshineAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

blue-genieCommented:
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;
etc

then set it to true in the complete handler

if both are true call the third function.


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lexshineAuthor Commented:
thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.