actionscript 3.0 progress/complete for multiple audio

Posted on 2008-11-17
Last Modified: 2013-11-11
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

Question by:lexshine
    LVL 39

    Accepted Solution

    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.


    Author Closing Comment


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
    There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
    The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
    The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now