0 Replies Latest reply on Dec 15, 2009 1:00 PM by mattk_ok

    Loader Problems

    mattk_ok

      Got a nifty preloader from Steven Sacks. Put it into my loader function. Have since run into a couple issues.

       

      I am creating an interactive timeline that loads external .swf s or images on different frames.

       

      The issue I now notice is that at the rate a user will download a file, if they navigate to another frame (where a different file is loaded), the preloader from the previous frame will remain and it kind of messes everything up. Basically, the preloader doubles up on the other frame/loader's preloader and then one preloader permanently remains.

       

      Hopefully that was descriptive enough - probably not, as I am exhausted from all of this.

       

      I tried to implement ldr.close(); to no avail and some other options that haven't worked. I'd appreciate any help.

       

      Here's the code. A good chunk was written by a fellow on this forum. Forgot who now, as it was months ago.

       

      Is there any way to kill the load with some type of conditional, or somehow tell it that when the frame changes the load stops? Any solutions?

       

      Thanks.

       

      ---

       

      var preloader:CircleSlicePreloader = new CircleSlicePreloader();

      var ldr:Loader = new Loader();

      var t:Timer=new Timer(10);

      t.addEventListener(TimerEvent.TIMER,fadeoutF);

      var fadespeed:Number=.09;

       

      function loadAndAddF(mc:MovieClip,urlS:String) {

      ldr.alpha=0;

      var urlR:URLRequest=new URLRequest(urlS);

      ldr.load(urlR);

      mc.addChild(ldr);

      ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, preloaderProgress);

      ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,loadCompleteF);

      }

       

      function preloaderProgress(e:Event):void {

      addChild(preloader);

      preloader.x = 365;

      preloader.y = 185;

      }

      function loadCompleteF(e:Event) {

      t.start();

      removeChild(preloader);

      }

      function fadeoutF(e:Event) {

      ldr.alpha+=fadespeed;

      if (ldr.alpha>=1) {

      ldr.alpha=1;

      t.stop();

      }

      }