Archive for July, 2007

Looping within a range


Something I have to do very often is looping a number within a range. This could be for a carousel navigation, a rotating banner or image slideshow, etc. The concept is simple, have a range, say 1 – 20, and simply call next() / previous() on it and return the new number, if it goes above 20, return to 1, if below 1, return to 20.
Read more…

New role at Digit!


After being freelance for the last 8 months, which has been pretty chaotic, I’ve accepted the position of “Senior Creative Technologist” at digit, a long established London agency.

It’s going to be a really interesting role for me, where I’ll carry on working with the Flash Platform (Flash, Flex, and hopefully some AIR apps), but also be involved in developing and designing physical interaction pieces using many technologies that I’ll be new to. Like Java, C#, mobile phone development, touch screens, motion sensors, whatever goes really. It’s going to be a great opportunity to broaden my knowledge.

RSS/Atom syndication made easy


A while ago adobe released their as3syndicationlib for easy access to RSS & Atom feeds by converting either RSS 1.0/2.0 or Atom feeds into generic data accessible via the IFeed interface. These libraries also require adobe’s corelib.

It literally took me 5 minutes to write a simple wrapper class to handle the loading of the feeds, and simply trace out the headlines of each item.
Read more…

AS3.0 Abstracts


Another thing I needed was a strict abstract class in AS3, again, public only constructors, and the absence of the “abstract” keyword from ActionScript meant a workaround.

[as]
package
{
import flash.utils.getDefinitionByName;
import flash.utils.getQualifiedClassName;

public class AbstractExample
{
public function AbstractExample()
{
if( Class( getDefinitionByName( getQualifiedClassName( this ) ) ) == AbstractExample ) throw new Error( ‘AbstractExample must be extended’ );

// rest of constructor here…
}
}
}
[/as]

I like this solution best as it doesn’t rely on strings for comparison as in Tink’s example. His method is shorter, and easier for typing. It’s down to personal preference really.

AS3.0 Singletons


While I’ve been getting up to speed with my AS3 over the past few months, there have been a few things which are really useful to know and took a bit of digging about to find.

As class constructors in ActionScript 3.0 must be public, there’s not a really clean way to force a class to be a singleton as there is in ActionScript 2.0 or Java say.

[as]
package
{
public class Singleton
{
public static var instance:Singleton;

public static function getInstance():Singleton
{
if( instance == null ) instance = new Singleton( getInstance );
return instance;
}

public function Singleton( caller:Function )
{
if( caller == Singleton.getInstance )
{
// instantiate class here
}
else
{
throw new Error( ‘Singleton is a singleton, use getInstance();’ );
}
}
}
}
[/as]

It’s pretty simple, you can’t call new Singleton() because the compiler will be expecting an argument, and if you do pass an argument, it will throw an Error because the caller is not the Singleton.getInstance method.

So you can only access this class by calling Singleton.getInstance().

Polar Clock 3.0 development


pc3.jpg
Just an update of how the development of the next release of the clock is going.

I’ve ported 90% of the engine to actionscript 3.0 now, and begun implementation of a config panel built using Flex Builder 3 (Moxie). I’ve now got the following language implemented: English, Afrikaans, Chinese, Danish, Dutch, French, Finnish, German, Greek, Hungarian, Italian, Japanese, Korean, Norwegian, Portugese, Portugese (Brazil), Polish, Romanian, Russian, Spanish, Swedish, Slovakian, Thai, Turkish and Vietnamese.

I have spoken to a guy at ScreenTime (who make screentime for flash) and they are sending me an updated version for windows in a couple of days, to match up the sizes of the config panels with the latest release for mac. Yeah, I bought screentime for mac + windows!!!

I’m hoping to launch version 3 of the clock on of before 21/07/07. Keep checking for updates!

So far there have been over 40,000 downloads of v1 and 2, it’s much much more popular than I ever expected!