shanethehat
shanethehat

Reputation: 15570

How to detect the presense of an SWF in the browser cache?

I have an AS3 application that loads various SWFs at runtime. The loading animation that is being used has a fairly long in and out animation that I don't want to show if the target SWF is in the browser cache.

So at the moment each SWF is loaded in as required using Greensock's SWFLoader in a basic manner:

var context:LoaderContext = new LoaderContext();
context.applicationDomain = ApplicationDomain.currentDomain;
loader = new SWFLoader("mySWF.swf", {name:"sectionLoader",context:context,auditSize:true,onOpen:onLoadInit,onProgress:onLoadProgress, onComplete:onCompleteLoadHandler, onError:onLoadErrorHandler});
loader.load();

My goal is to do something before calling loader.load(); to determine if the load operation will require the request to go beyond the browser cache, but before I get into R&Ding something I thought I'd ask if anyone has already done something similar.

A few more thoughts I've had so far:

Upvotes: 0

Views: 598

Answers (1)

Jevgenij Dmitrijev
Jevgenij Dmitrijev

Reputation: 2238

when you are doing any HTTP request, the responce comes up with HTTPStatus property. In AS3 you just need to chek if

HttpStatusEvent.status == 304

And for httpStatus in greensock library.

Basically 304 code means that no chages has been made on server side to the resource which user has requested. Which eventually leads to conclution that the resource is in the cache.

UPDATE

If this will not fit your needs try storing some variable for should you play the animation or not in Cookies or in Session variables.

Upvotes: 2

Related Questions