House of Cards - stereoscopic
I downloaded the animation data from Radiohead’s House of Cards music video from google code and rendered a frame in papervision. It took me about 10 attempts to download one of the zip files, but when I did manage to download it, you get a csv file for each frame of the music video. I open the csv in excel, and it show four columns of data, x; y; z; and intensity. I then formatted the data so I could dump it straight into actionscript as array data: p.push({x:X, y:Y, z:Z, c:C}); . I had to extend the ParticleField Object Class to allow me to drop the 3D data points from the animation Data. I then rendered two scenes side by side, each with a different camerax position to create a stereoscopic view. If you cross your eyes it really does look 3D.
I have added it as an experiment at robshearing.com
AMFPHP vs MediaTemple
I just set up AMFPHP on mediaTemple (gs) and I ran into a bit of a problem where I couldn’t get any messages back from AMFPHP. I’d get an error of NetConnection.Call.BadVersion which apperas as faultCode:INVALID_AMF_MESSAGE in the service broswer.
It turned out to be an incompatability with php 5.2 on the MT server. The solution was simple and elegant, I had to make an entry in the .htaccess file to enforce a specific php version. The answer is on knowledgebase:
AMFPHP incompatibilty with PHP 5.2
Pay Calculator
![]()
I have put up a new site, paycalculator.com.au that will calculate your net pay. It works for Australian incomes (single) and has the latest tax brackets. It also shows 2006-2007 and 2007-2008 financial years so you can see how the tax system has changed over the years. My pay is going up by $50 a month!
I used the same css as this blog but updated the header swf feature. I also added a more information section to help explain how the calculations work. There is a links page too, but it’s a bit dry.
I built this in responce to a lack of a good, simple, accurate online tax calculator. During my research, I became a bit suspicious of the calculator on the ATO website, as the numbers just don’t add up! I think there is a rounding problem that causes the calculations to drift. Moreover, all their calculators are awkward to use and often not complete or out of date. Having said this e-Tax rocks.
I’m also thinking of building a google gadget for it. I have a resized version ready to go. Building a google gadget is a pain. During the build I found that their API documentation was out of date and I also get a “can’t publish” error without explanation for no logical reason. At that point I gave up.
Arithmetic
I have just finished my first proper AS3 site (about time).
I inherited some work done by another developer, but it was left in a state - I think it got a bit too overwhelming for him. So I decided to rebuild the site structure and add a layer of logic behind the code. I used a simple form of mvc where the control and view were grouped. I also built it with swfAddress in mind. This added considerable complication as I have to have a single point of entry from which I could build the site from. The site structure was also described in xml so that it could be content managed - currently manually. I decided not to use E4X as the xml data’s structure was required. I have used E4X back in AS2, it is good for pulling data out of xml, but not so useful as a way of simply parsing xml into object data. I build a rock-solid XML parser in AS2 which would deserialise xml data into object/array structure. It has been used on hundrends of little jobs over the years and saves hours of development time. But as soon as I step into AS3 all my AS2 libraries are made redundant.
I learnt alot about AS3 whilst building the site. The hardest part was probably dealing with errors - in my case errors which occurred when I had to deal with a dynamic menu structure which may have 0, 1 or n nodes. In AS2 you can get away with using an undefined state as a valid condition, but in AS3 it will trigger a nasty error that will only express itself at runtime. Ouch.
The next phase of development will involve building a fileshare component to allow files to be uploaded/downloaded and commented upon by an administrator and client.
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


