3 Replies Latest reply on Mar 23, 2011 5:09 AM by lizsterine

    How to stop images that have started loading?




      I have 5 Image classes to load remote jpgs when a user first loads the 'screen'.  If they then click the next button, the currently loaded images should stop and the next 5 should load instead.  What seems to be happening is that those images in the middle of loaded (as in firing their PROGRESS events) don't die.  Looking in the browser status bar and using Firebug I seem them still going.


      Some of my COMPLETE events fire when the actual image currently loading hasn't finished loading yet, which I am assuming it's when the Image's previous url load completes, not the currently one.  I am running an unloadAndStop() and a source=null to all Image loaders before setting their source and calling load() for the new one.


      Is there an equivelant for Image as there is for Sound's to closeStream()?  Am I missing something or are the previous images not *actually* firing the COMPLETE event and my browser is lying to me?


      - Confused :-/

        • 1. Re: How to stop images that have started loading?
          lizsterine Level 1

          OK, just did a bit more testing with firebug.  I can confirm the COMPLETE events are fired when the first request images complete loading as well as the screen has to wait for the previously requested images to load before it starts on the new ones.


          I really need a killStream function or something to get around partially loaded images continuing to load in the background.  Any suggestions?



          • 2. Re: How to stop images that have started loading?
            pauland Level 4

            I don't believe it's possible to abort the loading of an image once it's been requested from the remote server. You need to make your application a bit more sophisticated to deal with that. If you don't want them seen make them invisible and remove them when loaded.

            • 3. Re: How to stop images that have started loading?
              lizsterine Level 1

              Thanks for the reply pauland.  I was affraid there might be no way of stopping them


              My issue isn't that they are SEEN, it's the fact they are still loading and regeistering events on 1 visual element.


              For eg:


              <mx:Image id="img1" complete="onCompleteHandler()" />


              In actionscript:

              img1.source = myImgURL;



              Then, while myImgURL is still loading, user clicks next:


              img1.source = null;


              img1.source = newImgURL;



              Even though I've replaced the source of img1 to newImgURL, the onCompleteHandler still fires when myImgURL has completed loading, not waiting until its current source, newImgURL, has loaded.


              *sigh* Looks like it might be back to the drawing board for me.