ActionScript Parsing, the YACC revenge :)

After my first attempts with ANTLR scanners in python/java I decided to start back with Bison/Flex again to see the difference in performances.
So first I need to wrote from scratch the grammar/lexer files using only the ECMAScript 4 specifications and much patience (the elastic grammar file help me a lot too).

After finishing a first version of the parser I tested it on the same file (75Kb actionscript file) which both java and python parsed in more than 1 second.
The result was unbelievable: 0.02 seconds for that file!

Then I tested it on multiple files, and for about 320 files of the whole adobe corelib library it took 220ms

Ok, the parser it’s not yet complete and doesn’t care about regexp and xml syntax, but its performance convinced me enough…
Now, the next step is to finish and test the parser and finally create a python library using pyrex, then a benchmark test again.

If someone is interested in testing the parser, download it (use “parser –help” form the command line for usage help), but remember this is only a first test.. not really helpful right now (I just wanted to share my text/parsing experiences).

Apollo tour continues…

Apollo & Flash9 (codename Blaze) tour continues, next time will be in Rome, Italy on 1st of December.
Mike Chambers and Mike Downey will be the speakers for this event organized by actionscript.it community.
During this event will be also explained Flex Data Services and AS3.
for more info about this event see the original entry @actionscript.it, also for informations about the event location.

Red5 with javascript python ruby and coffee?

Red5 (the opensource flash multimedia server) will support server side javascript, Ruby, Python and Java?
That’s terrific!
Well, it seems the next 0.6 RC1 version of Red5 will do that! The release is scheduled by next Monday and if that’s true I definitively will find the time to look inside it 🙂

XUL and XULRunner (co-starring flash)

Like you probably noteiced I got more and more interest in XUL and experimenting Firefox extensions in the last days.
After my first extension I decided to try something different and first I created a little (this time nothing new at all) and lightweight extension for grabbing flv videos while visiting youtube.com or video.google.com. It simply creates a statusbar icon and when there are availables flv on the page it will get active. Clicking on it let you save the current playing flv. You can also change the options and tell the extension to open the video using you favourite Video Player (Like VLC or FLVPlayer)

Install the getvideo-0.1-fx.xpi Firefox extension

When I did this extension comes also in my mind the idea of creating a simple Flash video player, just for practice. I was doing it using python/wxPython as usual.. but then I wanted to try using XUL  and package it with XULRunner (a runtime XUL runner, which runs xul applications like standalone applications).
First of all I have to say thanks to Darron Schall for his article on how-to embed swf files in xul. I was going crazy to understand all the steps for creating a valid xulrunner package..
As usual opensource sofware has bad and incomplete documentation. I need to look into one of the examples (chatzilla) to understand how it works.

Once I undertood that a new problem arise, the damn flash security sandbox error! When the xulrunner application starts it prompt also the security warning.. Oh my god!

After various attempts and after reading various articles on FlashplayerTrust I managed to solve the problem (or at least I think I’ve solved…).
In the installer a file named flvideoplayer.cfg will be copied inside the Application Data\Macromedia\Flash Player\#Security\FlashPlayerTrust direcory, and it’s content is

chrome:\\flvideoplayer\content\flvideoplayer.xul

In this way the embed swf file should has the correct permissions to communicate with the xul page using fscommand. I thought that my experiment was finished, but when I shown it to a friend he  asked me to add also the possibility to convert the .flv video into other formats (avi, mpeg, etc).
Well, fortunately there’s ffmpeg which does this job for everyone 🙂

Thus I included ffmpeg to enable video conversion. What I did it’s a runtime .bat file which wil invoke ffmpeg:

function execute_batch(bat) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
try
{
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(bat.path);
var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
process.init(file);
process.run(true, {}, 0);
} catch(e)
{
alert(e);
}
}

Ok, how to install this application.
In order to run correctly this application you first have to:

  • download XULRunner (I did not included in the installer because it’s about 10Mb).
  • Once downloaded from a command prompt, run xulrunner.exe –register-global (to register for all users) or xulrunner.exe –register-user (to register for one user only).
  • To enable the flash plugin (the Firefox plugin isn’t used, so if you launch the application you won’t see the flash embed object) you have to copy:
    {programs}\Mozilla Firefox\plugins\NPSWF32.dll
    {programs}\Mozilla Firefox\plugins\flashplayer.xpt

    into your XULRunner\plugins\ folder
  • Now just download yougrab! and install it.

Install YouGrab! (sorry but currently Windows only)

Mobile game contest

For the 2nd year actionscript.it community announced a mobile flash contest.
Another exciting new feature is the active participation of Jamba, which will be sitting in the jury panel, and will review all the games in the contest. If Jamba finds one or more games it considers interesting and fit for distribution through their network, they have agreed to offer a revenue sharing contract directly to the developers involved.

Prizes are

Flashlite category:
• 1st prize: Flash Studio 8
• 2nd prize: IRiver 2G
• 3rd: 3 O’Rilley Books

J2ME Category:
• 1st prize: Nokia N93
• 2nd prize: IRiver 2G
• 3rd prize: 3 O’Rilley Books

Go now to the actionscript.it contest page and submit now your game!
You have untl January 29th 2007 to submit your Game.

Ps. I’ll be in the jury too 🙂

From A to Web memories

Yesterday I attended the Italian Adobe conference, From A to Web, in Milan.
I like expecially the Mike Downey presentation, in which he showm us a sneak peak of the new Adobe project, codename “Apollo”.
A PDF+Flash+HTML plugin viewer for creating desktop applications (so, goodbye Zinc and similar?). Someone asked him which html engine was used in apollo, but without a precis answer, I think he was referring to Geko…
Also interesting the Mike’s explanation about the reason of the name “Apollo”.
That’s because the first Central codename was “Mercury” (early American program for launching humans into space) the second beta codename was “Gemini” (the second US manned spaceflight program), and Apollo was the first ship to land the Moon

Then he introduced also a preview of the new Flash9 IDE (currently in beta process, codename “Blaze”) and he shown some of the new IDE features. First of all the IDE has changed (like in almost new releases) and there are very cool workspace management cool features indeed.
A completely integrated Photoshop PSD import process. You can select which element of the psd file to be imported and how to do it, select one of the layers and import as movieclip, etc.. very nice for designers (There was a long applause).
Another features he presented was the Robert Penner export as ActionScript3 of timeline tweens. This should be for developers who need to transform the timeline motion tweens created by designer into code (Another long applause). For what I understand it creates an xml code which can be put into the timeline and which reproduce the original tween. But I also understand that the produced code can only be used into the same timeline (a timeline with the same number of frames)..,

FZip and Transform Tool

This post is just for pointing out a couple of very interesting tools for Flash9 I recently discovered.

  1. FZip: a little ActionScript3 class (Claus Wahlers and Max Herkender) which enable you to extract files from .zip files.
    Read the original post here
    Download and documentation are here: http://codeazur.com.br/lab/fzip/
  2. Transform Tool: a class (by About Trevor ) which allow to make every kind of transformations on flash display objects.
    See it here