Contribution to the as3corelib ResourceCache class
Luppis | Contributing, Flash | 24 Sep 2009 | 1 Comment »

At Flash On The Beach ‘09 I attended Mike Chamber’s session on “Advanced desktop development with Adobe AIR”. As part of the session Mike talked about some utility classes specifically for AIR in the as3corelib utility library – A library filled with many useful classes to aid in application development. One of these classes, ResourceCache, is built to download a file at a given url and same it to a local directory and when asked to get the same file again, it checks if such a file exists in the cache directory and uses that instead. Clearly a very useful class if you want to download assets and keep them available to the AIR application even when you disconnect from the internet and run the AIR app in offline mode.

Someone in the audience raised a question I was about to ask:

Can you set an expiry date for cached files?

Currently the ResourceCache class does not take into account if files should expire and a fresh version should be fetched from the server. Once the file is downloaded, it remains static until the cached file is deleted.

The original version of the class is used like this:

1
2
3
4
5
6
7
8
9
10
11
12
import com.adobe.air.net.ResourceCache;
import com.adobe.air.net.ResourceCacheEvent;

var cacheName:String = "MY_APP_CACHE";
var cache:ResourceCache = new ResourceCache( cacheName );
    cache.addEventListener( ResourceCacheEvent.ITEM_READY, onItemReady );
    cache.retrieve( "url_to_file" );

private function onItemReady( event:ResourceCacheEvent ):void
{
    var file:File = event.file;
}

The retrieve method in ResourceCache accepts a URL as a String and then checks if the file from that URL is stored in the cache directory. If it is, it dispatches an item ready event with the stored file attached. It the url has not been cached, it first downloads the file, writes it to the cache and then dispatches the event.

I made an update to the ResourceCache class to give it support for cached file expiration. After speaking with Mike Chambers at Flash on the Beach about it he recommended I open an issue in the as3corelib issue tracker and post my code in there. So I did: http://code.google.com/p/as3corelib/issues/detail?id=127
Mike said he’ll take a look at adding it into as3corelib.

Here is a quick breakdown of the updates:
Read the rest of this entry

Flash On The Beach ‘09 Brighton
Luppis | Flash | 20 Sep 2009 | No Comments »

FotB’09 Brighton is just around the corner and it’ll be my first time attending said conference/boozer. I was set to go last year but unfortunately got stuck at work with a launch of a large project coinciding. Then I had already bought the tickets to FotB’09 Miami when it sadly got canceled due to the economic state of the world. Well, not this time. There will be others from AKQA there as well, notably Aaron and Paddy, who’ll both be the whole duration of the conference.

Currently this is my most likely schedule for the event:

Monday

Tuesday

Wednesday

Like I said, these are the ones I’ll try to get to see. There might be issues with availability of space etc, but I’ll try.

I’ll be looking forward to seeing everyone who’s coming down there! Don’t be a stranger, say hello! :)

You … What?!
Luppis | Games, Life | 19 Sep 2009 | No Comments »

I’ve been enjoying table-top role-playing games for over a decade, both as a player and a GM. I enjoy the wondrous situations that can occur and coming up with creative solutions to overcome them – instead of just windmilling in. Having a GM go “You … what?!” is always a moment to remember, regardless is it you sitting behind the GM screen or someone else. Thinking “outside the box” is standard practice for roleplayers and I think it does lend a hand when trying to solve real-world problems as well. Also, speaking as another person to imaginary people does help your presentation skills.

I jokingly call my weekly gaming night my “weekly anger management class” although the truth might not be far from that. Being able to forget all normal wordly issues (like work) even for a few hours each week and spend it having fun with friends is a big booster for sanity.

London has a bunch of groups that meet weekly and play rpgs in pub function rooms. Finding a group like this is easy thanks to the ‘net. One of these clubs (the one I frequent every Wednesday) can be found here: http://londonroleplayingclub.co.uk/

Knights Of The Round Dinner Table

Knights Of The Round Dinner Table - Bundle Of Trouble: Vol 2 (c) Kenzer & Company

First blog post, finally.
Luppis | Flash, Life | 7 Sep 2008 | No Comments »

‘Twas bout time I got a hold of myself and got this blog together. I’ve been sitting on this domain for over a year and even before I registered it I had plans to put a blog together.

I put this “design” together some 5 months ago, when I had a lot of free time after moving to London from Helsinki, Finland. I’m sure many graphics designers can find alot of issues with it, but alas, I’m not a graphics designer, but a code monkey. I juggled different blog software for a while as well, but never actually got to converting the layout to a site. I finally decided to go with Wordpress, mostly because everyone uses it and there are lots of plugins available if I need ‘em. Then I started to have a life in London and the free time died down and creating a blog alongside with it.

But now, after many months, I decided to grab myself by the scruff of the neck and breathe new life to the comatose blog project. And after a day of tinkering what you see is the result. Not too bad, even if I do say so for my self. There are still some issues, but I’m ironing them out.

I decided I wanted stylized blog-post headers so I created them with Flash. I had to create a few custom functions in Wordpress in order to get the data I wanted correctly formatted and entered into the flashvars of the header swfs. Other than that, it was a breeze.

It’s done now, the fox is out of the bag.
Let’s see how far it can run.

About

Mikko

I'm a Finnish RIA developer named Mikko Tormala. I specialize in the Flash platform but do dabble with others web technologies as well (Silverlight, AJAX)

I'm employed by AKQA London as a Senior Creative Developer.

Topics of this blog are related to my work, hobbies & interests: technology, gaming, airsoft, whisky, cooking & life in general.

You can contact me at luppis@flashtronaut.com

Recent Posts

Latest Tweets

Categories

Rispekt / Friends

Archives

Meta: