5 Replies Latest reply on Sep 28, 2010 11:25 AM by kglad

    loadClip onLoadError

    SpiritOfTheWinds

      I've been getting some issues with what I think it time-out. I tried to find something that could help me, but I didn't find much...

       

      It seems that the loading process times out sometimes and it freezes the flash. To prevent that from happening, I thought about adding an onLoadError which loads a default image in the Library so that the slideshow continues what it was doing even if an image can't be loaded. But I can't get it to work... Here's what I was trying:

       

      I got in my library 2 items:

      1) JPG

      Name: fleur.jpg

      Instance name: imgFleur

       

      2) MovieClip

      Name: fleur

      Instance name: mcFleur

       

       

      function change_image(current_image,total):Void
      {   
          var mcLoader = new MovieClipLoader();

      // if there is an error, it should recall the onLoadInit right?
          mcLoader.onLoadError = function():Void {
              mcLoader.loadClip("mcFleur", _root.cadre.image_loader);
      // I also tried jpgFleur and attachMovie()
          }
         
          mcLoader.onLoadInit = function(target_mc:MovieClip, status:Number):Void
          {
              target_mc._visible = false;

       

              [Removed code]
              
              target_mc._visible = true;
             
              if(current_image  >= total - 1)
              {
                  current_image = -1;
              }
             
              if(total != 1)
              {
                    myTween = new TweenLite(_root.cadre, 2, {_alpha:100, onComplete:Activate_image, onCompleteParams:[current_image+1,total]});
              }
              else
              {
                    myTween = new TweenLite(_root.cadre, 2, {_alpha:100});
              }
          }

       

         mcLoader.loadClip(sujet_image_borne[current_image], _root.cadre.image_loader);
      }

       

      Thanks for pointing me out in the good direction!

        • 1. Re: loadClip onLoadError
          kglad Adobe Community Professional & MVP

          that's not going to work, as you now know.

           

          with what do you want help?  loading an external image file (like fleur.jpg) that's not in you fla's library or adding an image from your library?

          • 2. Re: loadClip onLoadError
            SpiritOfTheWinds Level 1

            I need to load either my fleur MC or JPG into my _root.cadre.loader_image (which is a MC on stage) when the onLoadError is called.

             

            Basically, it means that if loading (loadClip) an external image fails, I need to load an internal (library) image in its place to my _root.cadre.loader_image so that it doesn't freeze up the slideshow.

             

            It's in bold in my first post. That's where I have to load my internal image if the loadClip fails. I tried AttachMovie (since I did notice that loadClip only takes URLs) but it ain't working.

             

            Example of what I tried:

            _root.cadre.image_loader.attachMovie("mcFleur", "fleur_mc", _root.cadre.image_loader.getNextHighestDepth());

            • 3. Re: loadClip onLoadError
              kglad Adobe Community Professional & MVP

              if your fleur movieclip has linkage id = "mcFleur", you can use:

               

               

               

               

               

               

               

              function change_image(current_image,total):Void{
                 mcLoader.loadClip(sujet_image_borne[current_image], _root.cadre.image_loader);
              }

              var mcLO:Object={};

                  var mcLoader = new MovieClipLoader();

              mcLoader.addListener(mcLO);

               

              mcLO.onLoadError = function():Void {

              _root.cadre.image_loader.attachMovie("mcFleur","fleur_mc",_root.cadre.image_loader.getNextHighestDepth());


                  }
                 
              mcLO.onLoadInit = function(target_mc:MovieClip, status:Number):Void
                  {
                      target_mc._visible = false;

               

                      [Removed code]
                      
                      target_mc._visible = true;
                     
                      if(current_image  >= total - 1)
                      {
                          current_image = -1;
                      }
                     
                      if(total != 1)
                      {
                            myTween = new TweenLite(_root.cadre, 2, {_alpha:100, onComplete:Activate_image, onCompleteParams:[current_image+1,total]});
                      }
                      else
                      {
                            myTween = new TweenLite(_root.cadre, 2, {_alpha:100});
                      }
                  }

               


               

               

              • 4. Re: loadClip onLoadError
                SpiritOfTheWinds Level 1

                I'm sorry, in fact it was really a simple thing... my MC was staying invisible. I had to use the _root.cadre._visible = true in the onLoadError... which explains why everything I was trying didn't work... In fact, the attachMovie worked, I was just not "seeing it". My bad, sorry for that.

                 

                Thus, the code you wrote works perfectly! Thanks!

                • 5. Re: loadClip onLoadError
                  kglad Adobe Community Professional & MVP

                  you're welcome.

                   

                  (but i think you were doing alot more wrong that that.)