8 Replies Latest reply on Jun 24, 2008 5:31 PM by stick2theCode

    Handle the Network Connection Error ...

    xelabug
      The main purpose is to handle the Network Connection Error,
      when there is a Network Connection Error or pc loss the connection (remove the ETH cable),
      and it work in IE but not with firefox.

      When there isn't connection during play of sound1, Flash call "sound1.onSoundComplete" that point to an other frame, where i load an other es:Sound2.mp3, BUt there isn't connection and Flash call "sound1.onLoad" with "success=false" and that's OK because i handle the error for example retry to load every 10 Seconds.

      With Firefox when it happens the player call load sound2.mp3 but there isn't connection and it can't find the file (OK) BUT is NOT CALL the "sound2.onLoad" and STOPS it in this frame mute and nothing more happens.


      This is the sample Code:

      //on frame (1)
      sound1 = new Sound();
      sound2 = new Sound();
      ------------------

      //on frame (2)
      sound1.onLoad = function(success) {
      if (success) {
      //on load OK...
      trace("Sound1 loading ok...");
      } else {
      //on load FAIL...
      trace("Sound1 error ...");
      //call error function. (es: goto frame 1 and reload all.)
      _root.sounderror();
      }
      };

      sound1.loadSound("sound1.mp3", true);
      sound1.setVolume(100);

      //

      sound1.onSoundComplete = function() {
      //goto next frame and load the Second sound
      gotoAndStop(3);
      };

      -------------------
      //on the Frame-3
      //there is the same code but with sound2 and "onSoundComplete" -> gotoAndStop(2); for a loop of the two sounds.


      Thanks in advance for HELP ME.

      PLAEASE READ and Comment!!!
      This is my work! Sorry for the Bad English.

        • 1. Re: Handle the Network Connection Error ...
          kglad Adobe Community Professional & MVP
          your onSoundComplete functions should be defined before your loadSound methods.
          • 2. Re: Handle the Network Connection Error ...
            xelabug Level 1
            Thanks for your support, i have modify like your suggest but the problem continue.

            I've notice that in local work very fine also with Firefox. i try during play to remove in one shot all mp3 file, and it call the error handler function correctly, But if i put it on the web, when i unplug the eth cable, it stop after sound2 or 3.loadsond and write me back it in a text box, stop! it NOT Call the onload triger, and do not call the error function.
            WHY ?!? in local work whit all browser, and on web only with IE?
            HELP ME PLEASE!

            ---------------------------------------
            Post the new code:

            //Frame#1
            soundintro = new Sound();
            sounda = new Sound();
            soundb = new Sound();

            soundintro.onLoad = function(success) {
            if (success) {
            //find soundi - wait for onsoundcomplete...
            } else {
            //Sound error
            //Lunch error hander function.
            _root.sounderror();
            }
            };
            soundintro.onSoundComplete = function() {
            debug1 = debug1+("Trace-> soundintro Complete goto2..."+chr(13));
            gotoAndStop(2);
            };

            d = new Date();
            soundintro.loadSound("soundintro.mp3?r="+d.getTime(), true);
            soundintro.setVolume(100);

            stop;

            -------------------
            //Frame#2
            sound2.onLoad = function(success) {
            if (success) {
            //find sound2 - wait for onsoundcomplete...
            } else {
            //Sound error
            //Lunch error hander function.
            _root.sounderror();
            }
            };
            sound2.onSoundComplete = function() {
            debug1 = debug1+("Trace-> sound2 Complete goto3..."+chr(13));
            gotoAndStop(3);
            };

            d = new Date();
            sounda.loadSound("sound2.mp3?r="+d.getTime(), true);
            sounda.setVolume(100);

            stop;

            -------------------
            //Frame#3
            sound3.onLoad = function(success) {
            if (success) {
            //find sound3 - wait for onsoundcomplete...
            } else {
            //Sound error
            //Lunch error hander function.
            _root.sounderror();
            }
            };
            sound3.onSoundComplete = function() {
            debug1 = debug1+("Trace-> sound3 Complete goto back to2..."+chr(13));
            //Back to 2 for loop
            gotoAndStop(2);
            };

            d = new Date();
            sound3.loadSound("sound3.mp3?r="+d.getTime(), true);
            sound3.setVolume(100);

            stop;
            • 3. Re: Handle the Network Connection Error ...
              kglad Adobe Community Professional & MVP
              sound2 and sound3 are undefined.
              • 4. Re: Handle the Network Connection Error ...
                xelabug Level 1
                Yes ok, i mistake the declaration when i copy the code.

                sound1 e sound2 are define correctly.
                sound1 = new Sound();
                sound2 = new Sound();

                sounda and b was old and dosn't exist.

                You have same idea?
                Thanks for your time.
                • 5. Re: Handle the Network Connection Error ...
                  kglad Adobe Community Professional & MVP
                  copy and paste the relevant code. don't waste my time posting extraneous errors.
                  • 6. Handle the Network Connection Error ...
                    xelabug Level 1
                    OK, i've work very hard, and i've realized all that you need to try the problem.
                    here there is all link:

                    [on-line page that do the error with Firefox and not with IE]
                    http://www.xelabug.it/other/test-code/test-code.html

                    [ZIP Project+FLA]
                    http://www.xelabug.it/other/test-code/test-code.zip

                    [GUIDE]
                    1.Open Page in IE and Firefox.
                    2.During play there is a loop between sound1 & sound2
                    3.Cause Error connection -> Unplug ETH cable!!!
                    4. See the debug textbox - Scroll (Drag) at the end or copy and paste all text in the text box.
                    5. » IE retry to connect for retreve mp3 endless every 5 sec.
                    6. » Firefox Stop here when it can't find the mp3 and nothing other happend!
                    Why can't retry like IE?

                    Thanks.
                    • 7. Re: Handle the Network Connection Error ...
                      kglad Adobe Community Professional & MVP
                      there's a certain amount of help i'm willing to freely offer but that's beyond my limit. if you want to hire me to help, send an email via my website.
                      • 8. Handle the Network Connection Error ...
                        stick2theCode
                        Yeah, seriously, xelabug. Kglad's time is much more valuable than yours. I mean come on, did you expect to come into a forum and actually get help?! Everyone knows these places are for making ourselves feel superior by pointing out any little technicalities and perhaps answering in a condescending way - but that's only if we feel like it. Kglad is the only one in the whole world who is really doing something important and the only person who has a busy schedule. How could you NOT be aware that you were bothering this delicate genius by posting a question in a forum and that Kglad would just happen to read it?! I don't get it! Just because you are in a user-to-user forum and can find this kind of information for free by searching on Google, doesn't give you the right to think that Kglad shouldn't want to charge you money. Why would Kglad want to to go to all the trouble of acknowledging what you are trying to do when you didn't include every single line of code with every little semicolon in place? Your question and code must be flawless and totally complete, otherwise Kglad has the right to charge you for having to make obvious assumptions that variables are defined and various other things that are irrelevant to answering your question. Geez, Xelabug! Just WHAT was running through your mind when you decided to ask for help in a SUPPORT forum? You're ruining Kglad's life!!!!