Wired article

Wired got in touch a while ago asking about the PolarClock, and I’ve finally seen the finished article, it looks great!

pic after the jump…

Read more

iPhone PolarClock released

Screenshot2

Ed Kauffmann over at RayFlex has been busy developing the iPhone release of the PolarClock. It’s now ready and released at version 1.0. If you buy this application you will get free upgrades to future versions. Money raised from the sales of the iPhone version will go towards further development of both the iPhone and Mac/PC versions of the PolarClock.

It has a few new features, my favourite being the moon phase at the centre of the concentric rings. Good work ed.

You can get a copy here:

Crazy popularity!

I’ve been contacted a few times recently for info about the Polar Clock screensaver. It’s been hugely successful, far beyond my imagination. To date, it has been downloaded 295,676 times. This blog has has over 3,500,000 unique visitors in the last 2 years! That’s amazing!

There’s an article in Computerbild (Germany) and Wired US is doing a feature on it this month (link soon).

Play Balloonacy

raceacrosstheinternet.jpg

Myself and the top notch team of internet professionals at Poke have just finished this monster project, check it out. It’s mental.

AS3.0 MouseWheel on Mac OS X

I've finally found the time to port my SWFObject add-on SWFMacMouseWheel (catchy I know) to ActionScript 3.0 and SWFObject 2.0

There's now two examples in the zip, one for use with SWFObject 1.5, and a totally re-written version for use with SWFObject 2.0 (formerly SWFFix)

All you have to do in your main application class (or document class) is

Actionscript:
  1. import com.pixelbreaker.ui.osx.MacMouseWheel;
  2.  
  3. MacMouseWheel.setup( stage );

You can then add listeners to TextFields, Sprites etc etc as you normally would any other MouseEvent.

Example JavaScript to be used with the dynamic embed method

JavaScript:
  1. var vars = {};
  2. var params = { scale:'noScale', salign:'lt', menu:'false' };
  3. var attributes = { id:'testObject', name:'testObject' }; // give an id to the flash object
  4.  
  5. swfobject.embedSWF("test_as3.swf", "flashContent", "100%", "100%", "9.0.0", "js/expressInstall.swf", vars, params, attributes );
  6. swfmacmousewheel.registerObject(attributes.id);

I have updated the SWFObject 2.0 version to be more compact, and it also falls inline with the code style of SWFObject2.0. see swfmacmousewheel_src.js for the uncompressed version, deploy swfmacmousewheel2.js on your site.

Download source and demo here or view the demo online

AS3.0 Memory monitoring

I just came across the property System.totalMemory. It's very useful, especially for the engine I am currently working on, and dealing with AS3 garbage collection.

It returns the memory currently being used by the Flash Player. It's in bytes so it pays to clean it up slightly.

Actionscript:
  1. var mem:String = Number( System.totalMemory / 1024 / 1024 ).toFixed( 2 ) + 'Mb';
  2. trace( mem ); // eg traces "24.94Mb"

It seems this takes account of all instances of the flash player. For example, I have a logger/debug panel running in the sidebar of firefox, built in flex. As soon as I open this and it's initialised, it uses an extra 5 - 10mb of ram. So be warned, if you see a massive increase in memory usage, check you don't have loads of sites open with ad banners or other flash based stuff.

Back from Flash on the Beach

photo by BIT-101
I got back from Brighton yesterday, exhausted after 3 days of excellent sessions and some heavy drinking sessions too!

The high points for me were Mario Klingemann's "2D or not 2D, that is the question" talk about working with BitmapData. He showed how to make a "Magic Wand" tool a la photoshop. His process was impressive to say the least, and I'm very interested in playing with the paletteMap method of the BitmapData class.

The session from André Michelle was amazing, he demoed his PopForge sound synthesis engine. Generating sound entirely within flash at run-time. See the video below, this is all generated and manipulated in flash. It's simply amazing, I can't wait to get some time (after this post) to start messing around with sound in flash.

Read more

PolarClock on OS X Leopard

I've found a bug in screentime, the software used to pack up PolarClock as a screensaver. When run on Leopard, after the screensaver exits back to the desktop, the Function keys and any shortcuts to the Dashboard or exposé don't work. I have contacted screentime about this issue, and will post a fix a.s.a.p

AS3.0 JIT vs. Interpreted

I've been developing an application recently that requires large numbers of classes to be initialised as soon as the application is loaded. It's an isometric display engine, a la "Sim City", with a world map of 800 x 600 tiles, and multiple layers ( terrain, objects, transport networks etc) there's potential for over 100,000 instances!!!

I found ActionScript 3.0 and AVM2: Performance Tuning by Gary Grossman, which covers many aspects of how AVM2 is different from AVM1. The part I was interested in was about $init and $cinit (class constructor) functions being interpreted and everything else being JIT.

The initial setup of the engine runs over a timed loop (to stop script timeouts), and this was typically taking 20 to 30 seconds. After reading the above PDF, it became clear that class constructors are interpreted, not JIT compiled, so all I had to do was move the code out of the constructor, into an init() function, and call if after the constructor, this shaved a huge amount of time off the initial build of the landscape.

Some initial tests, with a for loop running from 0 to 10000 showed that in the constructor it took about 350ms, and called via another method, it took only 240ms. It is not always faster, but 90% of the time it's faster.

Read more

AS3.0 Better Singletons

I've found a better more robust way of enforcing singletons in AS3.0

Actionscript:
  1. package
  2. {
  3.     public class Singleton
  4.     {
  5.         public static var instance:Singleton;
  6.  
  7.         public static function getInstance():Singleton
  8.         {
  9.             if( instance == null ) instance = new Singleton( new SingletonEnforcer() );
  10.             return instance;
  11.         }
  12.  
  13.         public function Singleton( pvt:SingletonEnforcer )
  14.         {
  15.             // init class
  16.         }
  17.     }
  18. }
  19.  
  20. internal class SingletonEnforcer{}

Note: The class "SingletonEnforcer" is actually placed within the same .as file as the Singleton class, but placed outside the package{} parenthesis, therefore, the class "SingletonEnforcer" can only be accessed from within this .as file, so if the Singleton's constructor is called from anywhere else, you'll get an error.

Previous Entries