Archive for January, 2007

Loading JSON in ActionScript 2

Thursday, January 18th, 2007

Because I blew a few hours trying to figure this out the last few days, and finally cracking it, here’s how to fetch some JSON from a web service and have it processed into an object in ActionScript 2.

import JSON; // http://www.theorganization.net/work/jos/JSON.as

var jsonFetcher:LoadVars = new LoadVars();
jsonFetcher.onLoad = function(success:Boolean) {
	if (!success) {
		trace("Error connecting to server.");
	}
};
jsonFetcher.onData = function(thedata) {

	// ...
	// if writing a desktop app or widget, string manip or regexp
	// the JSON data packet out of the JS source provided by many
	// web services at this point..
	// ...

	try {
		var o:Object = JSON.parse(thedata);
		//mytrace(print_r(o));
		trace(print_a(o));
	} catch (ex) {
		trace(ex.name+":"+ex.message+":"+ex.at+":"+ex.text);
	}
};

// get the feed
jsonFetcher.load("url-to-json-feed.php");

// from: http://textsnippets.com/posts/show/633
// recursive function to print out the contents of an array similar to the PHP print_r() function
//
function print_a(obj, indent) {
	if (indent == null) {
		indent = "";
	}
	var out = "";
	for (item in obj) {
		if (typeof (obj[item]) == "object") {
			out += indent+"["+item+"] => Objectn";
		} else {
			out += indent+"["+item+"] => "+obj[item]+"n";
		}
		out += print_a(obj[item], indent+"   ");
	}
	return out;
}

BTW, what’s up with these JSON feeds that serve up JS that’s JSON plus some more code? That’s annoying — you gotta strip it out before you run the JSON converter :P .

Update: here’s the actionscript 2.0 JSON.as file people were looking for.

HTML Tags for the memories

Tuesday, January 16th, 2007

While Glutbook was waiting for it’s death knell to be pronounced upon it, I was using my windows desktop machine to re-launch my cousin Michelle’s popular website, Bunny Abandonware. We had worked on the site together before returning from vacation, redesigning the look and building it on a new back end (specifically, Word Press). Migration of the content was always going to be the hard part, but we put a Saturday and most of a Sunday aside to blitz the design, get the content in and migrated, and most of the hard work was done. A little more migration done by Michelle that week and it was ready for me to launch it.

So we did. And let me tell you, I’m really happy with how it turned out. It’s nothing revolutionary or taxing, but it was heaps of fun to redesign and make the templates as we went, with Michelle right there working with me.

This comment from The Abandonware Blog about Bunny Abandonware 4.0 really made me feel good:

Finally some nice scene news! Bunny from Bunny Abandonware has been mentioning is for quiet some time now but finally managed to get the new version of her website online and I must say (again) that it kicks ass! The unique colors used by only one abandonware site, the wonderfull [sic] navigation, the nice kinda web 2.0 style with all the gradients and big buttons ‘n stuff… damned pretty.

LOL, I did some Web 2.0 :rolleyes: ;) But I’m taking it all as a compliment. I believe that what Michelle does with her abandonware hobby is crucial for the survival, not just of the games, but of the memories. Abandonware, while legally dubious, is less a case of stealing and more the case of paying tribute. I keep telling Michelle she’s not just another retro gamer; she’s an archivist — the curator of her own museum. A museum where the exhibits remind her visitors of the way video games used to be, and where not only games, but ourselves as people have come since then, for better or for worse.

I think the best Christmas present I gave myself was when for Christmas I gave my brother a huge pack of water balloons . I had moved out of home to Wellington and I had come to realise that I missed him. We had fun in that back yard that one day, running around with the sole purpose of cooling off and having a blast. But I did it with the motive of having that memory to look back on — a careless, happier day in my history. It worked, and it’s one of the most cherished memories I have. It didn’t cost a lot.

Memories are worth gold, but the most valuable memories are the ones that cost the least.

My life in the Glutter Black

Tuesday, January 16th, 2007

I got my first Mac when I was in Sydney for Web Essentials 2005 (now called Web Directions); a nice 12″ iBook G4. I called it squishy and I made him mine and he became my squishy. Actually, it’s name was Glutbook (Along with my phone GlutPhone, a usb thumbdrive GlutKey, a bluetooth apple mouse GlutMouse, another thumbdrive Revenge of GlutKey, and a bluetooth Mighty Mouse MightyGlut).

On saturday, Glutbook wouldn’t power up. It made loud fan noises, but no apple chime :( After trying to use the Apple website to self diagnose and repair, I bundled it up in my bag, and took it down to MagnumMac, hoping that the service department would be open.

Nope. Not available till Monday, and I wouldn’t get a verdict till then. Paying for ‘same day’ service and checking Glutbook into what could either be a hospital or a morgue, I left feeling worried about having to shell out to replace it. Talking to my friends, they said it sounded like a fried logic board; that’s basically the motherboard of the laptop — the bit that everything plugs into, except on a laptop, things don’t really plug in so much as are soldered permanently onto it. If it fails, you replace the lot.

Monday rolls around, and I get the call — Glutbook died. Probably from overheating due to a faulty fan. NZD$1500+ to repair it. Crap. Oh well, at least the hard drive, the RAM, and the two batteries I had for it are still good (stay tuned).

I ask to be transferred to sales, and I discuss a replacement over the phone, discuss finance, and end up calling the financiers to get pre-approved, which surprisingly happens over the phone — none of this two-hour waiting crap. I tell my boss the sob story and ask if I can go sort it out and get a replacement.

I really wanted the Black 13″ MacBook 2.0GHZ, but after discussing it with my friends, I was essentially paying $400 for 40gb in a matte black shell, so I asked for the one below it, which comes in white. Oh well, I thought, the HDD is user serviceable on the MacBook, unlike the iBook — if it’s not a big deal, I can put a bigger hard drive in it later. But they were out of stock! Screw it, and as my friend Matthew said on the phone, once you go black, you’ll never go back.

So in order to introduce, here’s my first post on this blog made on GlutBlack. She’s great — class act all the way! I love it’s solid keyboard, the integrated iSight camera, the magsafe power connector, and the immense improvement in speed over Glutbook. I can totally recommend the MacBook range to anyone who thinks it will suit their needs. I mean, I didn’t need an aluminium MacBook Pro, what with me mostly reading and editing text and working on the odd Fireworks PNG file.

Life and Fitness in Karori

Tuesday, January 16th, 2007

Life Update.

I haven’t blogged this yet, but I’ve been working at Natcoll Design Technology for over a year now. I started as a part-time Multimedia tutor, and now I’m the Diploma of Web Development Course Coordinator for the Wellington campus. I teach on average 18 hours a week, with the rest in prep, paperwork and management. Really fun job, besides the paperwork ;) I even get to help out with the tech support sometimes… but eh, what ya gonna do?

. . .

Mid last year, I moved from downtown Cuba St to the boxed valley suburb of Karori (said to be the largest suburb in the southern hemisphere) with the intention of eating better and getting fit.

I’ve got the getting fit thing working somewhat: Mountain Biking. Karori has a world renowned mountain bike park running up, and most importantly, down, the back of it. I got my bike at the start of December, a nice GT Avalanche 3.0, and I’ve been slowly discovering the many tracks it holds. It’s really a beautiful place, and with summer turning up finally, I’m going to make the most of it.

I originally got the bike to commute to and from work every day. Karori is up in the hills, and the city, where I work, is at sea-level. It takes me 15 minutes door-to-door every morning, and depending on my route, 30-50 minutes coming home uphill. I don’t really enjoy exercise, but at least I know I’ll have achieved something every day, no matter how my day might have been.

My del.icio.us bookmarks this week

Tuesday, January 16th, 2007
  • Over 1000 free 16×16 icons for your creative usage. All Creative Commons Attribution 2.5 licenced too! HAH! Thanks Kere :)
    (tagged: art cool creativecommons design dev download downloads free freeware graphics icons illustration image images layout media pictures programming set stock templates web web2.0 webdesign webdev webdevelopment webmaster work resources)

Add me to your del.icio.us Network | All Glutnix’s bookmarks