Archive for the ‘Optimisation’ Category

HowTo: Improve your workflow with Snippets, comments and ‘dormant’ variables

Sunday, January 25th, 2009

I use FlexBuilder. I used to use FDT but the code-completion, hover-over links and - most importantly - ability to compile from MXML that FlexBuilder offers eventually tempted me away. Still, there’s one thing about FDT I miss: it wrote A LOT of code for me. Nothing complicated, stuff like getters & setters that are tedious and time consuming. It was great that FDT could take that off my hands.

These days, with FlexBuilder, I don’t have that any longer. Which isn’t great but I’ve managed to concoct a  workaround using ‘Snippets’, comments and ‘dormant’ variables, which has sped things up for me and which could do the same for you.

Let me explain…

(more…)

HowTo: Build a multi-language dynamic Flex application

Monday, November 3rd, 2008

One of the projects I worked upon over the summer was destined for the South-American market and therefore needed to display in both Spanish and Portuguese. It was a microsite built in Flex and needed the capacity to alternate between these two languages at any given time. From the user’s perspective, a single button click should be sufficient to translate the entire site’s text from one language to another instantly. Looking around the web I couldn’t find any answers so I sat down and worked out a solution myself.

Here’s a sample app using English and my second language Swedish:

(more…)

AS3 Optimisation Tip II: Avoid String concatenation

Tuesday, August 26th, 2008
// this:
var id:int = 0;
var name:String = id.toString();
 
// as opposed to this:
var id:int = 0;
var name:String = "name_" + id.toString();
 
// and ESPECIALLY this:
var id:int = 0;
var name:String = "obj_" + "name_" + id.toString();

Conclusion: each additional concatenation adds roughly an additional 20% to processing time

Twenty percent is a lot if you’ve gotta run through a long loop and assign properties to a whole bunch of properties. Anywhere where you can avoid concatenation you should. Storing values indexically with integers seems by far the best way to go with this, whether you are storing your data in Arrays, Dictionaries, Objects or your own bespoke class. Concatenation is going to drag you back wherever you use it.

AS3 Optimisation Tip I: Use public properties

Thursday, August 7th, 2008

// this:
public var id:int;
 
// as opposed to this:
private var _id:int;
public function get id ():int
{
    return _id;
}
public function set id (id:int):void
{
    _id = id;
}

Conclusion: Public properties are roughly 20% faster than private vars with getters & setters

If you don’t need to run any code on a class property why bother writing a getter and a setter for it? It’ll take longer to type (FDT users aside), make your code fatty and run slower. Tell me the advantage in all that. Instead, why not just use a public variable with the caveat that if you need to turn it into a private variable with a getter and a setter later you can?

AS3 Optimisation Tips

Thursday, August 7th, 2008

I did a bit of generative art in Flash earlier this year. A decent bit too, thanks to some good tip-offs by snail-brain supremo Peter Passaro. Wanting to get it running as efficiently as possible I spent a day back in May trying things out and discovered a couple of tips that didn’t feature in John Grden’s awesome AS3 optimisation list. There were quite a few and I’ll try to get through them over the next few weeks.