Caching Loaders - need to reset loaded Swf to frame 1

Hey folks,

A (probably very simple) problem for someone.

I got roped into fixing a simple slideshow Flash app that was requesting each slideshow page (a swf) from the server each and every time the page appeared in the slideshow - even though once the slideshow looped, those pages had already been loaded once. It seemed like a simple fix: instead of creating a new Loader object for each page, I just stashed the loader in an objCachedPageLoaders global var and loaded subsequent requests for the page from there. No problemo!


  ... 
  if (!objCachedPageLoaders.hasOwnProperty(url))
  {
    var thisLdr:Loader = new Loader();
    thisLdr.load(new URLRequest(url)); 
    objCachedPageLoaders = thisLdr;
  }
  addChild(objCachedPageLoaders);
  ...

The problem is that it appears that once the swfs have been run once, they end up on their final frame. When I addChild() the cached loaders, they’re no longer added at the first frame.

I need it to reset them to frame 1 each time the addChild() function is called.

I don’t see anything in Loader’s documentation to do this…

Any idea?

  • Ben

Oops, got it.

        if (!objCachedPageLoaders.hasOwnProperty(url))
        {
            var thisLdr:Loader = new Loader();
            thisLdr.load(new URLRequest(url)); 
            objCachedPageLoaders = thisLdr;
        }
        // if this had already been cached, reset it to the first frame
        else
            objCachedPageLoaders.content.gotoAndPlay(0);

Thanks anyway!

  • Ben