JSON - by the code for the code
Just finished building the json flash feed:
http://blog.robshearing.com/wp-flash-json.php
I used a handy php JSON parser to encode the string. I’m not entirely convinced about JSON. Evangelists go on about it’s inherent readability, however characters have to be escaped and this results in some messy looking text. I see this notation best suited for code and not for humans to read. It’s best if it’s encoded by code and then decoded by code and never sees the light of day. In this respect it is a very readable notation, lightweight and easy to ingest.
For example:
encoding (using PHP JSON parser):
$output = $json->encode($json_feed);
decoding (using adobe’s AS3 JSON parser):
var myObject:Object = JSON.decode( jsonString );
I don’t think it’ll ever replace xml. If I have to manage the data myself I will opt for xml - I can add comments, I can add CDATA, I can waste time deciding whether to use attributes or text nodes and I can take pleasure in making it look nice. But if I just want to shift a big chunky object from one platform to another I’l be encoding with JSON.
Custom rss feeds
I’m working on setting up this wp blog to manage the blog and to act as a CMS for a flash site. I have a Category Visibility plugin that hides website posts and only shows blog entries in the blog. For the non-blog posts I’m adding some custom fields that will be used to link to assets. I can then expose these categories to the flash site via rss.
Blog posts:
http://blog.robshearing.com/wp-rss2.php
or
http://blog.robshearing.com/feed
or
http://blog.robshearing.com/?feed=rss2
Actionscript experiments feed:
http://blog.robshearing.com/wp-rss2.php?cat=8
Work feed:
http://blog.robshearing.com/wp-rss2.php?cat=7
I am however finding flaws in this model. The problem is twofold - dealing with those custom fields and making my life easier when I parse the data in flash. I’m thinking of either adding the meta data to the rss feeds, making a custom feed, or make a bespoke JSON feed. I don’t want to add meta to the rss as it may start to break the feeds compliance, also I don’t want no trouble if I upgade WordPress. Making a custon rss fleed is boring, so I’m going to attempt to build a bespoke JSON feed…
AS3 - learning the ropes
I’m getting stuck into AS3 to build my new site and it’s not as straight forward as I first thought. Almost everything I have learnt and taken for granted I now have to revisit and rebuild. Generally however, I’m pleased with all the new coding procedures and class re-writes that adobe have given in the updated language.
Here are three interesting ‘features’ I discovered yesturday:
Stage
Stage can only be accessed though a visible displayObject.
I discoved this when tying to build an AS3 stageManager class. I didn’t want to make the class extend a sprite and have to add it to the displayList. So I decided to pass it a displayList object as a reference that it uses to measure the stage size.
AS3 Singleton
You can’t make the constructor private! So the old singleton is broken. I googled this problem and found that many people pass the constructor a private variable or method so it can only be successfully implemented internally. Problem is that the class looks a bit messy. Then I discovered another implementation by Daniel Hai on http://www.onflex.org/code/
package
{
public class Singleton
{
private static var instance:Singleton = new Singleton();
public function Singleton()
{
if( instance ) throw new Error( "Singleton and can only be accessed through Singleton.getInstance()" );
}
public static function getInstance():Singleton
{
return instance;
}
}
}
E4X and namespace
I was attempting to read a feed from here: http://kuler.adobe.com/kuler/API/rss/get.cfm?listtype=rating
If you look closly the swatches are on nodes under a kuler namespace:
…
<kuler:themeItem>
…
<kuler:themeSwatches>
<kuler:swatch>
<kuler:swatchHexColor>468966</kuler:swatchHexColor>
</kuler:swatch>
</kuler:themeSwatches>
…
</kuler:themeItem>
…
I haven’t come accross this notation before. In AS2 I could just barge in and parse the nodes as “kuler:themeID”. So this led me to discover the namespace class. Whereby, if I understand it correctly, you target the nodes within a specific namespace. Combined with the beauty of E4X, my query became:
var kuler_ns:Namespace = xml.namespace("kuler");
var hexList:XMLList = xml..kuler_ns::swatchHexColor.text();
Isn’t that pretty.
astronaut - music and flickr
A series of tag searches from flickr is done against lyrics to a song. Results are unexpected and amusing.
http://www.avoision.com/experiments/astronaut/
This has got me thinking. I might have a go at ths some time, afterall I’ve already built the engine:
flickr rss reader
Eames’ information machine
A short animated film written, produced & directed by Charles & Ray Eames for the IBM Pavilion for the 1958 Brussels World’s Fair. The movie topic is the computer in the context of human development, more specifically it traces the history of storing & analyzing information from the days of the cavemen to today’s age of electronic brains.
Lee Brimlow on AIR
A video has just been added to the onAIR tour:
http://onair.adobe.com/blogs/videos/2007/08/01/lee-brimelow-transitioning-to-the-desktop-with-adobe-air/
Lee is great and he works at such a great company too. As for all this AIR, I really have to get started. The results are so much similar to ZINC, but with a much cleaner interface (and I presume more stable and less quirky)
Erik Natzke - new hero
I heard a lot about Erik Natzke way back in flash 5 days. He had a really intersting experimental showcase site. I remember his work was massively respected. Then he disappeared - his site went down and I didn’t hear much about him. So the other day I stumbled over a video of his at FITC in 06.
http://video.google.ca/videoplay?docid=-1458352919661594741&q=fitc
This guy is a true master of the flash meduim and is always pushing it to it’s limits. His work was on his site for a while but now it redirects to his blog:
http://jot.eriknatzke.com/
I loved his swarms and ribbons. So I tried to replicate:
swarm_1
swarm_2
ribbon
Trying to customise WP
The style of this site comes from Brazil. I don’t know who he is, I just spotted the style at video.onflex.org. I have however got really stuck into customising it for my own pleasure. I have stripped out all that sidebar nonsence and categories and reduced it to a simple clean interface. I also added a little flash piece instead of an image.
Now, I’m not all that fussed about maintaining a blog, I doubt anyone will read it. Primarily, I just want to lean about the software. But more than that, I also want to use it as a CMS for my new site.
I’ll use the title and post for the heading and description, but I also need a link to the flash/image/flv/java file assets. For this I’ll use a custom field. When that is sorted I’ll need to add hidden categories for two of the features on the site - work and experiments. I can then get feeds of these categories that can be use to poulate the flash site. Nice.
My first AS3
I saw this mesh wave thing, and I thought it would be a good effect to replicate in AS3. I had a good idea that the wave used perlin noise mapped onto a 3D perspective. Check it.
I built it in AS2 to see the speed difference and it was remarkable. It was a good learning experience to learn AS3. With AS3, the language has finally matured to be in the same league as JAVA and C#.
Next on the list is papervision, Digg API and that Flex CMS…


