12 Replies Latest reply on Dec 19, 2009 7:35 PM by carl schooff

    loading time questions...

    r_tist Level 1



      All 'play' button functionality is in Flash format. Well, it looks like most tracks need to load (in the background) before they will play. Plus this is holding up images that also need to load on the same page. Due to this, if the end-user navigates to another page, they cannot due to the hold-up. What can I do about this? We have also compressed the music files down to 2.5mb each. Will the solution be to reduce the music to short snippets? We really don't want to do that though.

      It's: christopherpayne.com/listen


      Please advise, thanks much!

        • 1. Re: loading time questions...
          kglad Adobe Community Professional & MVP

          1.  preload anything that needed for you swf to function correctly.


          2.  prioritize the importance of the loaded objects and load them sequentially.


          3.  display the preload progress when appropriate.

          • 2. Re: loading time questions...
            r_tist Level 1

            OK, so you think I should add a preloader to all of the SWF buttons?

            How can I prioritize the importance of the loaded objects and load them sequentially? The tracks are displayed on the page in order of importance so don't they load from top to bottom? Please advise further...I'd really like to try to clean this up.

            Another thing: I cannot understand why on IE the very top row of tracks as well as the 1st track on the 2nd row are not even displaying the "play" button?? How and why can this be? - It's in the source code, and displays in Safari. I am dead curious as to how this can happen even though the page display at the bottom of the IE window reads "done" for status of loaded items on the page.


            Thanks much!

            • 3. Re: loading time questions...
              kglad Adobe Community Professional & MVP

              i can't answer questions that are specific to your particular project because i'm not familiar with your particular project.  all i could do is give general guidelines.  you'll need to apply those guidelines to your own project.


              but, in general, loading assets sequentially means loading one asset, using preloader code to determine when that completes loading and then loading the next asset, using preloader code then loading the next asset etc.


              loading assets using a for-loop is anathema to sequential loading.

              • 4. Re: loading time questions...
                r_tist Level 1



                How do I use preloader code to load the assets? I'm not at all familiar with this - are there any tutorials that can show me exactly how I need to do this?

                Or any more you can explain to help me; I really need to clean this up...it's just not going to work with the way I have it now (taking far too long to load because the page is waiting for everything to load in the background)


                Thanks for your advice!

                • 5. Re: loading time questions...
                  kglad Adobe Community Professional & MVP

                  are you using as2 or as3?

                  • 6. Re: loading time questions...
                    r_tist Level 1

                    It's AS3, thanks!

                    • 7. Re: loading time questions...
                      kglad Adobe Community Professional & MVP

                      here are the essentials of a sequential as3 loading scheme:


                      var assetA:Array = [files to be loaded sequentially];


                      var tl:MovieClip = this;
                      var index:uint=0;


                      function loadStart(){
                          tl["ldr_"+index] = new Loader();
                          // add to stage if appropriate


                      function loadComplete(e:Event){

                      • 8. Re: loading time questions...
                        r_tist Level 1

                        OK, so just to clarify, where exactly do I insert this script - each play button is a button with it's own AS inserted on the first keyframe in the top most layer. As your script will represent all buttons overall on the page, would this inserted in a stand-alone, separate file called myScript.swf (for example)? Is that how you do it? Or would it be a .TXT file? If so, where and how do I call upon that in the HTML page? Or would the browser read it and "know" to do this automatically?


                        Also, where you say [files to be loaded sequentially], in there, do I note the actual Mp3 names? Are they simply separated by a comma or a semicolon?


                        Thanks again!!

                        • 9. Re: loading time questions...
                          kglad Adobe Community Professional & MVP

                          i think you're going to need someone to help you with each step of this or to do this for you.


                          if you don't have any resources to walk you through this, you should consider hiring someone to do this for you.

                          • 10. Re: loading time questions...
                            r_tist Level 1



                            I'd like to learn how to modify myself. Can you please answer my questions, or provide a link to a tutorial?

                            Otherwise, is there a more helpful forum you'd recommend so that I may work through this w/ the advice of others?



                            • 11. Re: loading time questions...
                              carl schooff Level 3

                              I just looked at your source and page activity.

                              It appears you have roughly 24 individual swfs each loading their own mp3 at the same time the page is loading.


                              If you had 1 or 2 swfs, maybe that could be considered acceptable, but 24...no.



                              You are really going to have to completely revisit how this page is built or else it will never load or perform well.


                              BEST QUICK SOLUTION:

                              Have one swf that contains all your "play" buttons. When a play button is pressed, the proper song will load and play.

                              This solution has been battle tested and provided in many different visual flavors:

                              http://activeden.net/searches?term=mp3&type=files cost:$6 time:1hr


                              GOOD DIY

                              start learning how to do this yourself:

                              http://flashexplained.com/sound/loading-an-external-mp3-file-with-actionscript/ cost:$0 time:2-4hrs


                              This is the most basic and easy AS2 way of doing it. Once you have followed this tutorial you should then try to make the sound play when you press a button.



                                   coolTune.loadSound("song.mp3", true);



                              You can either then figure out how to make 1 swf have multiple buttons with multiple sounds... or make 24 different swfs, atleast they won't load sounds until the user requests.

                              • 12. Re: loading time questions...
                                r_tist Level 1



                                Thank you for the info...this is what I was looking for. I read through the tutorial, and I would like to know something - Just by looking at this AS I already have attached to each individual play button, in order to get it to preload; wouldn't I just need to add: ", true" (without quotes of course) directly after the name of each mp3? Isn't that all I need to add in order to get every track to preload so that it streams?? (see my actions below) Take a quick look and let me know - that will be a very simple fix, then, and solve my issue if that's all I need to add. THANKS!!


                                var loadSnd:URLRequest = new URLRequest("Icelands.mp3");

                                var thisSnd:Sound = new Sound();


                                var sndTrans:SoundChannel = new SoundChannel();




                                play_btn.addEventListener(MouseEvent.CLICK, playF);

                                stop_btn.visible = false;

                                stop_btn.addEventListener(MouseEvent.CLICK, stopF);


                                function playF(event:MouseEvent):void{

                                sndTrans = thisSnd.play();

                                play_btn.visible = false;

                                stop_btn.visible = true;



                                function stopF(event:MouseEvent):void{


                                stop_btn.visible = false;

                                play_btn.visible = true;