Category: Flash/Actionscript
Ghost in the Shell

Every now and then you find funny stuff in the trace() logs from the flash player. Usually it’s just frustrated debugging statements, or the occasional one-line “Stop looking at my underwear” statement to fellow developers. But this one takes the cake, an inspired full-on Ghostbusters-themed ASCII invite to apply for a job at blip.tv. Nice.
FDT, AS3, and OS X
Just set up the trial of the Flash Actionscript IDE FDT. There’s a few things to keep in mind when installing it on Mac OS X, however:
1) You need to download the standalone Flex SDK, and point to that in the Core Libraries Settings (Preferences > FDT > Core Libraries > AS3 Core Libraries). If you’re running the standalone Flex Builder and try to point to the SDKs in that install it won’t work. Make sure that there’s no spaces in the path to the SDK, either, otherwise FDT won’t be able to find it. I put mine in ~/Documents/sdks/flex_sdk_3/
2) You need to copy the playerglobal.swc file to a location without spaces as well, as suggested here. I put mine in ~/Documents/fdt/playerglobal.swc.
Those were the two big differences from the instructions in the Basic AS3 tutorial (Help > FDT User Guide > Getting Started > Basic AS3 Tutorial).
I’ll be putting FDT through its paces, comparing it to TextMate of course. I have a feeling for big projects it’ll be pretty useful, since it has the project-level hinting/completion that TextMate lacks.
So Flash, the Registered TM Symbol, and a URLRequest walk into a bar…
At work we ran into a little issue on how to pass the registered trademark symbol ® from flash to the user's mail client via a mailto: call. We originally tried jamming it into the string like so:
-
var tmessage:String = "%26%23174%3B";
-
var _req:URLRequest = new URLRequest("mailto:?subject=hello&body=" + tmessage);
-
navigateToURL(_req);
We had hoped that the email client would receive the string and decode it properly, but instead it simply rendered it as ®. Searching the web for help was complicated because "register" and "registration" appear so often in forms and unrelated content.
In the end, some experimentation and reading of the documentation for the URLRequest class led us to this solution:
-
package
-
{
-
import flash.net.URLRequest;
-
import flash.net.*;
-
import flash.display.Sprite;
-
-
public class SendToFriend extends Sprite
-
{
-
-
private const MESSAGE:String = "This message is from dirtystylus®";
-
-
public function SendToFriend(): void
-
{
-
send();
-
}
-
-
private function send():void
-
{
-
var _req:URLRequest = new URLRequest("mailto:");
-
var variables:URLVariables = new URLVariables();
-
variables.subject = "hello";
-
variables.body = MESSAGE;
-
_req.data = variables;
-
_req.method = URLRequestMethod.GET;
-
navigateToURL(_req);
-
}
-
}
-
}
The URLRequest class has a data property, to which one can assign a URLVariables object containing stuff that we were trying to jam into the string as name/value url-encoded values. Assigning the variables to the data property also automatically urlencodes them before the URLRequest is sent, so in the final solution we just plugged the "®" symbol directly into the string, and it was urlencoded properly and emerged in the email body intact.
Plugout - Flash Player Version Switcher
While developing the recent AllStateGarage.com site I had to do regression testing on different versions of the Flash Player, to make sure that both the swfobject embedding script and the built-in ExpressInstall upgrade functionality were working properly. After doing a bit of searching I found Plugout, which in a brilliant twist of fate was written by Aaron Smith (the guy behind RubyAMF that we used on the AllstateGarage.com project).
Plugout is a command-line utility that makes switching to different versions of the flash player easy. You can specify the plugin, version number, and browser. It's smart enough to restart and run the browser under Rosetta if the plugin version is PPC-only. For example, to switch to Flash Player version 9.0.28 in Safari I fire up Terminal and run:
-
plugout -p flash -v 9.0.28
You can also add different plugin versions as they get released, including debugger versions of the plugin (the debugger versions are denoted by a "d" following the version number). For example:
-
plugout -p flash -v 9.0.115d
The only wrinkle I ran into when using Plugout was that Ruby is required for it to work. This isn't a big deal to Leopard users, since Ruby is included, but before I upgraded to OS X 10.5 I just ran the plugout command in a shell session launched from within a Locomotive Ruby context. Speaking of Locomotive: development has been halted on the project, mostly because of Ruby's inclusion in OS X Leopard.
AllstateGarage.com

AllStateGarage.com is today's Site of the Day from The FWA. This is a project I've been working on for the last 7-8 months (on and off), so it's nice to see it pick up some accolades. The project was a lot of fun from the programming standpoint — we got to use RubyAMF to hook into the Rails backend, so there was a lot of digging into new technology.
The Squid and the Stallion has more on the project.







