Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Cache frequently used assets...  (Read 8584 times)
Hyakugei
Jr. Member
**
Posts: 11


View Profile Email
« on: May 09, 2008, 10:55:31 »

I'm in the beginning stages of creating a game using AS3/PMVC. So far, things have been going well. One aspect of the game that i've been pondering is how to externalize the assets, but reduce the total amount of network traffic required to load the assets for each level. Since most of the assets will be re-used from level to level, i'm thinking of using the following idea. You can load the assets (in my case, swf's and bitmaps) using the URLLoader, with the dataFormat set to BINARY. This binary data would be held in a Proxy. When the level mediator needs an asset, it asks the Proxy for the Binary data. It then uses a flash.display.Loader object's loadBytes() method to "create" the instance of that asset.

I read about this on Colin Moock's blog, although he doesn't detail it (its an excerpt from his book, which i've yet to get). He also uses the Socket object, rather then the URLLoader one. I went with the URLLoader because its just so darn easy to use. 

I don't know if this is how others do it, but it seems like a good idea to me! :)

jos
Logged
creynders
Jr. Member
**
Posts: 18


View Profile Email
« Reply #1 on: May 12, 2008, 08:40:15 »

AFAIK there's really no need to create a custom cache. Your browser's cache will do just fine.
I don't know the chapter in colin's book, but I want to bet that it has to do with stuff that doesn't get cached automatically (like, for instance, video streams, rpc responses, etcetera)
If you're using swf's and bitmaps this isn't necessary and will only bloat your application size.
Logged
Hyakugei
Jr. Member
**
Posts: 11


View Profile Email
« Reply #2 on: May 12, 2008, 01:32:32 »

Well, you are making the assumption that the user is using a browser and that the users browser cache is bigger then the total size of all your content.

But other then that you are right, i just thought it was a cool trick ;) and could prevent extraneous net fetches.
Logged
creynders
Jr. Member
**
Posts: 18


View Profile Email
« Reply #3 on: May 13, 2008, 12:45:49 »

You've got a point there.
But when it's not shown in a browser all external assets are still placed in a temp directory, so the same principle applies. (If I remember correctly the cache won't be re-used in a new session though, which is a difference with the browser's cache)
Logged
Pages: [1]
Print