Jump to content
Search Community

Skip preloader animation if content cached

alex_s test
Moderator Tag

Recommended Posts

I have a preloader swf that uses loaderMax to load settings and assets for a main swf (also an asset)

 

If a user clicks a link from the movie and the browser is redirected to a new address (_self) when they click back, the preloader move plays through its sequence again (albeit quickly)

 

Have we got a way to skip the pre-loader completly once the content has been cached?

 

many thanks,

Alex

Link to comment
Share on other sites

Well, your swf still needs to reload when the browser goes back to that page, so it kinda makes sense that it'd need to go through and load up the assets as well. I don't see a clean way around that (nor would I want to frankly). Since the files would be cached, it should move very quickly through the queue (as you said).

Link to comment
Share on other sites

I've used this technique successfully -- start a timer when you call the loader (You may need to adjust the timing depending on the weight of the assets you're bringing in) If the timer fires before your load finishes, show the progress animation...

 

// -------------------------------------------------------------------

var queue : LoaderMax;

var loader : ImageLoader;

var t : Timer;

 

queue = new LoaderMax({name:"loader"});

loader = new ImageLoader("http://someimage.jpg", {onProgress: onLoadProgress, onComplete: onLoadComplete } );

queue.append(loader);

t = new Timer(500, 1);

addEventListener(TimerEvent.TIMER, onTimer);

 

load();

 

function load():void

{

// start the load process and the timer

queue.load();

t.start();

}

 

function onTimer(e:TimerEvent):void

{

// load hasn't finished yet, and the timer has gone off

// build your progress animation into a sprite or movie clip that starts out hidden

// and show it if the timer goes off

TweenMax.to(progressAnimation, .5, { autoAlpha: 1 } );

}

 

function onLoadProgress(e:LoaderEvent):void

{

// do something based on the load progress

progressAnimation.scaleX = ImageLoader(e.target).bytesLoaded / ImageLoader(e.target).bytesTotal;

}

 

function onLoadComplete(e:LoaderEvent):void

{

// load is done, stop the timer

t.stop();

}

Link to comment
Share on other sites

  • 2 months later...

Thanks for the tip off Robert, I'll try your technique and report back.

 

I have used shared objects in the past to make a note that the content is cached and skip the % animation.

 

Jack,

take my client mini site:

http://www.next.co.uk/babyboutique/

whether you agree flash is a suitable solution for this or not, but the client uses these mini pages a lot.

 

The mini pages act as a hub linking to product sections elsewhere in the site, so after clicking to view a product, if they hit back on the browser having to sit through the % animation (in this case the cubes) is counter to a nice experience.

 

If you would have any pointers for extending the classes etc. I would be happy to work through a clean (ish) solution.

 

Will let you know on the success of my efforts, perhaps Roberts technique will work best.

 

regards,

Alex

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...