views:

50

answers:

1

Greetings,

I am writing a networked flash application. The server (an independent C++ app) sends resources for the flash client to manipulate and/or display, eg, images and sound. I'm assuming that the browser stores these resources in its cache. Since the resources can be pretty big, I don't want to resend them from the server each time the client restarts the app. I can't use the LSO (flash cookies) because those won't update if the cache gets independently cleared by the browser or the user.

So for the flash gurus.. 1) Is there a way to detect if an item has been cached, eg to query the browser cache for a crc or something? Maybe load the object offscreen and (somehow) detect if it shows up? -OR- 2) Is there a way to avoid using the normal browser cache and cache things myself, in some kind of larger LSO?

Thanks for the help.

A: 

no you can't. but if you have a preloader for the resources, so the user sees something is loading it should do just fine. if the resources are already in the cache, then they won't see the preloader, the app will just appear. and the request for the images/sounds won't be made to the server so no traffic there. if they aren't in the cache, they will see the preloader so you're exactly there to begin with. i see no reason why you are trying to manipulate the cache in any way in your case.

TheBrain
well, the problem here is that the resources aren't stored in the SWF or anywhere local I can preload them from-- they come directly from the server (say, on the first run) and then (I assume) get stuffed in the browser cache. I don't see how I can detect if the client actually has a resource so it decide if it has to make the request from the server.
flashnewb
yes. you can show a preloader for downloadable resources. if you load the image for example with whatever loading method given by flash (urlloader, loader, whatever) you have events for progress and loaded complete, and so on. you know how many assets you have to download, divide a progress bar to that number, and get the first resource. when that's done, increment the progress bar, and load the next one and so on.
TheBrain
as my s/n says, I'm a flash newb, so please be patient with me here because I'm still not getting it. Let's just try an example. Suppose you have a very basic server that just sends images to the flash client via a socket. The client displays the images as they come in. What I'd like to do is have the server first send some identifier for the image (a name or a checksum or something) that the client can then respond with "I have it" or "send it". How does the client determine this?
flashnewb
wait. are you using flash.net.socket to get resources ? if you're sending resources through a socket they can't be cached by the browser. and how are you loading sound that way since you can't write bytes in a sound object in flas ? better yet. paste some pieces of code (in pastebin.com or someting)
TheBrain
well, I'm actually just prototyping different web frameworks to work with an existing server (the thing sending the resources). If Flash is incapable of caching dynamically generated resources (even if they are converted to an image format and displayed), then it won't work for me. So I take it that, in my example above, the server would always have to send the resources to the client? Meh. Thanks for the help.
flashnewb