Just another flash platform blog 

Making Flex Better

November 19th, 2008 Posted in Flex | 2 Comments »

Today I came home to work to a package I’ve been waiting for from Adobe. A while back I got an email from them saying they’d like to thank me for my involvement in the Flex 3 Beta by sending me a tee shirt.

A few weeks ago I received an email showing me the design and it turns out that on the back making up the Flex logo are all the names of the other people who also recieved the Tee. There are a few big community names on there so I feel quite honored (Ok I know its a Tee Shirt - simple things / simple minds maybe) to appear next to them.

The last name on the list (its alphabetical order) was Xavi Beumala - senior Adobe Consultant and www.madeinflex.com co-founder who I’ve recently worked with on the upcoming BBC iPlayer Download Manager written in AIR.

Its odd enough walking round with your own name on a tee shirt, let alone someone you’ve worked with. Anyway, that wont stop me, I’ll be wearing it tomorrow :)

Thanks Adobe you’re really rocking my world at the moment!

Here are a couple of images of the Tee Shirt:

Front and back of my tee shirt:
Front and back of my tee shirt

Thats me in the middle of the ‘F’:
Thats me in the middle of the 'F'

Share/Save/Bookmark

AS3 Benchmark: Ternery vs Tradional Conditionals

November 6th, 2008 Posted in General | 2 Comments »

I regularly use the ternery operator when I think it neatens up a piece of code, but recently a colleague at BBC mentioned that he thought that ternery conditional assignments are slower than regular ones. When he mentioned it I was of the opinion that it wouldn’t make a difference since the compiler would recognise both as the same thing and end up with similar bytecode.

Since then its been in the back of my mind to run some benchmarking on the two approaches to see what difference it actually makes. Before I go into the results of the heres a example of the two in case you dont know what I mean:

The regular if/else assignment:
var str:String;
if ( i%2==0 )
{
str = "true";
}
else
{
str = "false";
}

The ternery assignment:
var str:String = ( i%2==0 ) ? "true" : "false";

In the test I ran both of the above over 1,000,000 iterations and then ran each one of those tests 100 times to get a decent average. Here’s a typical result:

regular: 70.6ms
ternery: 69.5ms

As you can see very little difference. In fact I ran the same test several times and the ternery assignment always ended up slightly averagely quicker than a regular assignment. Occassionaly it was faster by as much as 10ms on average, but I think this was probably an anomally. Looking at the individual figures there was normally only 1ms in favour of the ternery.

One millisecond over one million iterations is probably not a significant difference, though if you were running such iterations frame after frame, or trying to save the world then it might be worth doing… and regarding “neatening code”, remember, neat doesnt always mean more readable so use it carefully.

I ran the tests on a Toshiba laptop, 2GB RAM and a Dual Intel 1.47 GHz, you can find the test source here. Have a go an post your results.

Share/Save/Bookmark

Eco Programming

November 5th, 2008 Posted in AS3, General | 1 Comment »

It’s very tempting to think performance doesn’t matter. After all, not all of us are writing code that goes into millions of iterations per frame or that performs complex algorithms. Even with quite large RIAs it’s possible you’ll only deal with very small data sets and only loop over a handfull of items per array. So for most of us it’s easy to think “well that works” and move on. It is often the case even when you’ve spent time implementing the sweetest architecture or the latest design pattern not to revisit the guts of what you’ve written.

Wherever I work I like to encourage people to think more about performance. Even when the program is quite small, thinking about the finer details of how your code executes can help to understand the enviroment your code runs in and ultimately the machine itself (this is more and more important for ActionScript developers. As the language improves so the responsibility of the developer to understand what happens under the hood increases too). If you haven’t yet built a large application then you very likely will in the future so equiping yourself with the understanding now will stand you in good stead for when the time does come.

If you’re anything like me then planning for the future is often not enough motivation to do something now, especially when you have deadlines and managers hanging over you and the like. So perhaps you need another motivation to think about the performance of your code.

Enter the “Enviroment” (I’m tryng not to cringe as I write this, it IS an important issue after all).

It’s not just about how your apps’ performance impacts the user while it runs, it’s also about it’s reach. By reach I refer to how many people are going to find and use your program. Even if it’s a small frame script on a flash advert, that advert could very well be seen and run by millions of people. All of a sudden 10 iterations over a loop become 10 million iterations. One millisecond of CPU time becomes several minutes. Eco Programming is about getting the best performance even when the impact on the user is negligible in the hope that the overall efficiency might have a significant combined effect.

The energy consumption of CPU’s has become more important in recent months. CPU benchmarking laboritories are staring to pay attention to how energy efficient processors are. The image below is taken from a recent report which benchmarks CPUs for various things, but includes wattage at 100% load.

Though it’s not clear how long the tests were run for, it’s not difficult to imagine how by reducing the overall CPU time of your app by as little as millisecond you can begin to save several Watts over the full reach of the product. If we all were to do this then we might make a significant impact on power consumption.

If saving the world isnt enough motivation to get performance tweaking, then maybe just that its good fun is enough for you :). Here are a few links to get you started on improving the performance of your programs:

http://osflash.org/as3_speed_optimizations
http://mikegrundvig.blogspot.com/2007/05/as3-is-fast.html
http://gamedevjuice.wordpress.com/2008/02/15/seven-tips-about-performance-optimization-in-actionscript-3/
http://www.danielhai.com/blog/?p=55

There are loads more… get googling!

Share/Save/Bookmark

Flash Develop Talking Sense - Continued…

October 23rd, 2008 Posted in General | No Comments »

Last month I posted about a Syntax pack I’d written to enable colour coding (amongst other things) for the SenseTalk language in Flash Develop.

The other post has more details about installing it etc and why you might want to use it, but I’ve been receiving messages saying that it doesnt work. This original zip was missing the file that references the syntax file itself so hense for anyone installing the syntax files it didnt work.

Anyway, I can now remedy this by posting the complete archive file. Apologies to anyone that thinks they need them :) The original post also links to the correct files now too.

Download the files here:
SenseTalk Syntax

Share/Save/Bookmark

FMS 3.5 BETA

October 22nd, 2008 Posted in Flash, Flash Media Server | 2 Comments »

Oh cruel world why do you mock me?! (Imagine dramatic pose)

Late last week Kevin Towes posted on the Flash Media lists that Adobe we’re recruiting for the FMS 3.5 pre release programme. Given that I’m interested in all things media with my current role at BBC iPlayer I thought that would be a good thing. So I fill in the forms and wait…

Meanwhile: (Imagine comic strip) … this weekend I decided I’d upgrade my flash to CS4 to get stuck into the new features it was only £165 (not bad - even with the silly mark up we get in the UK).

Anyway to my delight on Monday I check my email and discover I’ve been invited onto the FMS 3.5 pre release programme… yipeeeeee…. and they have given me a free licence for Flash CS4… nooooo! Had I waited just a couple more days (or checked my junk mail folder for that matter) I could have saved my self that £165. Still never mind I can have legal copies on both my PC’s now.

I’m most looking foreward to testing the dynamic bitrate switching so I can implement it for iPlayer when the CDN’s upgrade. There tends to be quite a delay from release to full deployment on the big CDN’s so no doubt I have plently of time, but thats no reason not to get playing ASAP. Much fun ensues…

Share/Save/Bookmark

Banter with BBC iPlayer

October 15th, 2008 Posted in Flash Media Server, General | No Comments »

First off, this is not another big annoucement from the BBC!

What it is though is a website developed by Stefan Richer, which allows you to register and chat using one of his Flex/FMS chat components along side the BBC’s EMP with simulcast playlists. So you can watch BBC live online and chat with like minded people. Great idea, similar ideas have been thought about in the iPlayer team, but with limited resources and a road map of cool features as long as your arm, this sort of innovation wont be happening this year.

From a personal point of view (i.e. in no way representing any offical stance from the BBC) I think its great to see a community of people growing up around the iPlayer, it all helps keep the philospy of an open internet alive. Sites like Stefan’s will certianly continue to raise the profile of the iPlayer and hopefully help to fuel innovation and creativity within the team too. Good work Stefan.

Go and have a play http://www.bantertv.com

Share/Save/Bookmark