ActionScript 3 madness

Many people in the big corporations thinks now it’s time to move to AS 3 their oldies (I heard of people still using AS 1 code). But seems they are only interested in quick transcodings (concept which isn’t possible, at all, unless we are talking about 10 lines of code).

In Pescados Software we use AS only as a tool, so we moved to AS 3 when we needed it, but allways for new projects. Re-usable AS 2 code was finally thrown, as most of times we found it wasn’t so “re-usable” at all. I think AS 3 is a good starting point to make new “solid” stuff. Although I’m not specially satisfied with the performance and “features” of the newer versions of Flash Player, I think AS 3 is a pretty decent language which many people coming from other programming languages (such as Java or PHP) adopted easilly, and others like us (more in the “design side of Flash”) can adapt-to, coming from the background usages of AS 1 and 2.

Still, from the end-user point of view, I don’t see many advances (watching silly HD videos in Youtube is no more than watching silly videos at all, only to mention one of the best new features of the latest FP versions, quite unrelated to AS 3 at all). If we spend the new power of AS 3 creating special effects (which aren’t so special at all), I will feel like a monkey with a gun. We must evolve and create the web 2.0, before the web 3.0 arrives so soon.

Advertisements

WindowSWF, mix ActionScript and JSFL for automation and productivity

It’s a long title for a post which could, in fact, be the only message without extra ellaboration. But I’ll ellaborate a bit, because I think this is a underrated feature I love in Flash, which allows to the end-user a full experience of automation and high detail customization of the Flash IDE. This post is for those of you who don’t know about it.

You can create a UI in Flash/ActionScript, link it with JSFL (Javascript Flash, a javascript-based language to drive the Flash IDE) and create your own utilities panel with customized solutions for your daily work. Such as this:

windowswf

I use every day the buttons in this panel. The first button in the top-left corner, for example, will convert selected items in the stage to named movie clips. It’s a silly task, but some times, before I worked out this solution, I was forced to do it manually hundreds of times in a single day (!) –> select, F8, insert name for symbol, insert name for instance in the stage.

My most impressive automation task was one responsible of arranging, making certains changes and publishing thousands of FLA files in a row, which reduced various workdays to 20 or 30 minutes I could spend in a delicious capuccino while the machine was working by itself.

This isn’t a guide, so I’ll describe briefly the mechanism:

1. You have some need (usually automation of repetitive tasks in the Flash IDE).
2. You write a JSFL command in order to replicate what you use to do manually –> most of times *any* task can be duplicated via JSFL. If you don’t believe it, create a new document, make a rectangle, group it, then go to the menu Window > Other Panels > History. Everything listed in there is pure JSFL recorded which you can copy to the clipboard. More complex tasks will require heavy tweaks, though 😉
3. You create a FLA file with a button (or buttons, progress bars or whatever) linking to the JSFL command. Usually, JSFL commands are stored in the “Commands” folder of Flash’ main configuration dir and can be accesed as well from the Commands menu. You can even assign them a shortcut. But sometimes you run out of shortcuts or you can’t remember more shortcuts (!). This is the time when you need to create your own toolbar with that bunch of customized daily tasks. You call the JSFL command from ActionScript as follow:

myButton.onRelease=function(){
	MMExecute('fl.runScript(fl.configURI + "Commands/selec-to-movies.jsfl");');
}

This example is using AS 2 syntax, but that isn’t a problem, very simple to port it to AS 3. Basically, you call the ActionScript method of the same name, which executes JSFL code. This method is *only* available to “WindowSWF” panels, XMLtoUI dialogs (created on the fly usually by JSFL commands, that is another topic) or UI components. Obviously, no sense out of the Adobe Flash IDE.
4. Move the resulting SWF file to the WindowSWF folder of the config folder (next to Commands, Components, etc.).
5. Relaunch Flash. Now you can access your brand new panel from the menu Window > Other Panels, and it will behave just like any other utilities panel (more or less, you will learn some tiny details when you do it real).

And that’s all. Even if you don’t write your own JSFL solutions, you can still create a WindowSWF panel and link it to others’ JSFL commands you can find in Adobe’s Exchange web site.