[flashpro] image caching
Timo Stamm
t.stamm at macnews.de
Wed Aug 17 11:56:57 EDT 2005
Micah Freedman wrote:
>
> Thanks for your response, but I need a bit more detail and some
> clarification.
You have to ask more precise questions. Try not to put different
questions and assumptions into one sentence.
> On Aug 17, 2005, at 4:24 AM, Timo Stamm wrote:
>
> I guess what I was
> asking is does the flash player have an image cache? (I presume yes.)
No, it does not.
>>> If I want to use the same loaded image in multiple places within a
>>> movie,
>>
>>
>> This is not possible.
>
>
> What!? Of course it is.
No, you can not use *the same loaded image* in multiple places, but you
can load the same image into various places.
I can load the same image (from a URL, e.g.
> "flowers.jpg") into multiple movie clips at different locations on the
> stage.
Yes, you can *load the same image* multiple times, but you can not use
the same loaded image.
> The question is, does the flash player treat them as separate
> downloads (which would be annoyingly inefficient),
Yes it does.
or does it recognize
> that "flowers.jpg" is already being loaded by both movieClips, and just
> download it to the client once?
No, the flash player does not recognize that an image has already been
loaded.
There is a difference between the Flash Player (standalone) and the
Flash Plugin (Browser-plugin).
The standalone player has its own HTTP-Client and it downloads all
ressources on its own. AFAIK there is no caching at all.
The plugin makes all requests through the web browser. This means that
the cache of the browser is used.
This means that you have no control over the cache, and to be exact, you
can not even assume that there is a cache.
> Hmm... well, I'm building an image viewer app, and I'm looking for
> advice/discussion of best practices in terms of when and how to load
> the images for maximum efficiency from the user's point of view.
From the usability standpoint, it is much better when the user does not
have to wait for images to be loaded. So they should be preloaded.
You can preload all images at the start, before the user can view any
images. This has the drawback that the user has to wait quite a long
time before he can view any image.
You can preload all images while the user can use the application. This
works quite well when the images are viewed in the same sequence as they
are loaded. But if the user is free to select any image - the last one
in the loading sequence, for example - he will have to wait until all
previous images are loaded.
The solution to this problem is a queue. The queue has 1 (or more) slots
that are used to preload images. If the user requests an image, the
request is put at the top of the queue. This ensures best possible
responsiveness and good preloading.
If there is a chance that the same images is loaded at different places
in the application, it is possible to assume that there is a cache, and
load images that have already been loaded independantly of the queue.
>>> duplicateMovieClip?
>>
>>
>> Does not work with loaded movieclips.
>
>
> too bad.
Yes.
You can generate an swf file containing the image on the server side,
though, and it should be possible to attach the image from the swfs
library to various movieclips.
>>> Does it just "know" that it's already downloaded that image when
>>> you ask for it again if the url is the same?
>>
>>
>> What do you mean with "it"?
>
>
> By "it", I mean the player, or the movieClip which reuses the image.
No, there is no way to know if the image has already been loaded. You
can do this with your own code, but since you have no chance to reuse
the loaded image, it is mostly useless.
> (This is similar to my question above about using the same image in
> multiple places.) If the images were in my movie's library, I could
> reference them as many times as I wanted and after the first time,
> they'd just be cached and wouldn't have to download. I'm not sure that
> this is true with the images which I'm loading from the filesystem.
Images from the filesystem are only available to the standalone player.
They will be reloaded every time you request them.
> Thanks again,
>
> Micah
No problem,
Timo
More information about the FlashPro
mailing list