Flash Switcher for Windows, OSX and Linux

With the upcoming release of Firefox 3 I thought I had to verify my extensions to see if they work with the new Firefox version too.
For the first version of flash switcher I did two different extensions for Windows and Mac. That was a problem for maintenance.

This time I wrote the extension from scratch and I decided to make it as much as cross platform as possible. Moreover I wanted to make the installation of new plugins easier than in the previous version of flash switcher extension ( where you had to copy manually the plugin file into the extension’s directory.. ).

Thus now this extension works ( at least with my tests and people who tested it ) with Windows, OSX and Linux. Specifically it has been tested on:

  • Windows XP
  • Ubuntu linux 8.04
  • OSX Leopard and Tiger

Also the installation of new plugins now it’s easy. Just click on the installed flash plugin and click “save”. Well, I think it’s quite easy 🙂

The only issue with the new extension is that it’s quite big because it comes with 2 flash versions for every OS platform. So it’s about 14Mb.

I also did a couple of video to show how it currently works on different platforms. Currently there are 2 videos (ubuntu and osx usage).

Flash switcher Ubuntu

In order to use this extension ( if you want to try it ) you need Firefox 3.
P.S. If you want to add more flash players to the extension, download and install the version you want from the flash player archive page.
Once a new flashplayer has been installed onto your system you can save it into your flash switcher archive using the “save as” menu item of the flash switcher.

Install flash switcher

Runtime expression evaluation in ActionScript

Finally I have a bit of free time to write down this post.
Some days ago a guy on the forum asked about how to evaluate at runtime simple mathematical expressions with support for symbols and function calls.

Now that the eval function have been removed from the language for reasons I’ve not enought time to talk about, we need to parse and execute those expressions manually.

I built a simple Actionscript library that can be used to parse mathematical expressions: it has support for function calls, for variables and it is able to convert the expression into a postfix rappresentation if you may need it. The expression parser is quite simple and have been built manually following some concepts related to programming language compilers; it includes a Scanner (or lexer – however you want to call it) to tokenize the expression, a Parser that convert the expression into an Abstract Syntax Tree and a simple routine that evaluates that AST using a Symbol Table as evaluation context.

There are no comments inside the code right now; I hope to find a little bit of time to write an in depth discussion about this topic. In the mean time you can continue reading the entry for a general explanation about how does the code works and for some examples that may be useful.

Here is a simple example that shows how does the code works:

import it.sephiroth.expr.CompiledExpression;
import it.sephiroth.expr.Parser;
import it.sephiroth.expr.Scanner;
public class Example
{
public static function run(): void
{
var expression: String = "sin( x / ( 8 / 2 + (-0.12 + 2.3) * x / x ) ) * 100";
var scanner: Scanner = new Scanner( expression );
var parser: Parser = new Parser( scanner );
var compiled: CompiledExpression = parser.parse();
var context: Object = {
x: 100,
sin: Math.sin,
cos: Math.cos
};
trace( 'Postfix:', compiled.toString() );
trace( 'Result:', compiled.execute( context ) );
}
}

Before I forgot, you can download the source code here with a simple example included.

Continue reading

Finally a code coverage tool for AS3!

Today is really a good day.

I was waiting for this kind of tool since a lot of time, and thanks to Joe we can finally do Code Coverage of our Actionscript code.

The project is hosted on Google Code, and can be obviously downloaded for free; the project is born after some tests of the author, that edited the Flex compiler to include additional informations that are used to generate a code coverage log that then can be read by softwares that display the output in a more user friendly and fashion way.

For anyone who doesn’t know, Code Coverage is a good practice used most in software testing, that is applied to understand how much source code is touched by our tests. This way a developer knows if a test covers all the source code (or the required portions) and can tune his tests if they don’t.

This project is probably one of the first born after the public release of the Flex SDK source code, and we are pretty sure that there are much more projects coming in the near future.

Finally we can do a little bit of Code Coverage in Aviary 🙂