Capture key sequences in ActionScript 3. AKA The Konami Comeback.

6/06/2009

Contra Konami
Lately the internet has had a wave of sites using the cherished Konami Cheatcode to reveal easter eggs or similar functionality in the site or app.

I wrote a (crappy but working) class to implement such functionality in ActionScript about a year ago here.

I decided to polish it up a bit for the benefit of myself and anyone else and in the process ended up creating a small utility class to work with keystrokes in the process.

You can download the (fairly self-expaining) classes and a sample project right here, or read on for a bit of explanations.

(Text) Keys.as.
(Text) Konami.as.
(Archive) Neatly zipped + example.

Read the rest of this article »

3 Comments

Adobe Updodger

21/04/2009

Do you use any Adobe products? Tell me if this sounds familiar: “Oh hai! I need to update some totally unrelated stuff on your machine! You know, some camera raw stuff or InDesign whatchamacallits, so I’m just going to force you to quit all your browsers, because lordy lordy who knows what might happen if you coincidentally were looking at interwebs while I was installing this shit. Woohoo!”

Yes… The old adobe installer/updater. Let me count the ways I hate you. Quite a few! So, more out of spite than anything else I started checking out what browsers might not be sniffed up by the dreaded ugly beast that is the Adobe Installer/Updater. Turns out they’ve been thorough. Fluid gets away with it, but it’s really not that great for anything but site-specific stuff (which it was made for, and indeed does very well).

So in the end I wrote my own web browser, and of course I did it in AIR (Adobe Integrated AIR Runtime… RAS!).
So let me advice you; This is NOT a good browser, and it is NOT much of a feat to have written it, but it WILL work during an Adobe installation does its thing, and it IS fucking hillarious to use Adobe technology to subvert Adobe technology.

The source is available in the app itself, and you’ll notice that I’ve used this guys styles to pretty it up a bit. Knock yourself out if it takes your fancy. If you install the app you’ll get a very basic browser. A URL field, back and forward history buttons and a search field. Impressively it seems to remember your logins from other browsers, which is not my doing at all. Clicky clicky badgy badgy to install.

Please upgrade your Flash Player This is the content that would be shown if the user does not have Flash Player 9.0.115 or higher installed.

No Comments

Clean flashlog.txt with a keystroke

5/02/2009

Scenario: You’re working with the Flex SDK and you’re tracing messages to the Terminal via flashlog.txt. The damn logfile has heaps of clutter in it from the last project you were working on, and you want to clean it up.

Solution: Save this snippet and assign it a Quicksilver hotkey:

1
2
3
4
try
    do shell script "rm ~/Library/Preferences/Macromedia/Flash\ Player/Logs/flashlog.txt"
    do shell script "touch ~/Library/Preferences/Macromedia/Flash\ Player/Logs/flashlog.txt"
end try

Result: You are happy. Go drink beer.

No Comments

ActionScript 3 URL validator class

2/02/2009

A fairly common task in ActionScript projects is to deal with URLs in dynamically loaded text. Whenever I faced this prospect I usually ended up with some half-assed searching for “http://” and then indexOf(” “) to determine when the URL had ended and then smacked a <a href> on either side. Which pretty much meant that “http://___||/**.tasty_cheese_omelete” would be acceptable while “google.com” would not.

Hence I always promised myself that next time I’d write a proper class to deal with URLs so that this bullshit wouldn’t pass anymore.

Regular Expressions have always scared the bejeezus out of me, but I realized there was probably no other option when looking for something that has a valid URL structure. It was surprisingly easy to find some fairly good examples for what I wanted to achieve, and surprisingly difficult to get any of them to work in ActionScript. I’m blaming it on the AS implementation of RegExp, and I’m sure ActionScript is blaming it on my implementation of dumb.

After some swearing though I managed to determine whather a string had the proper structure of a URL but it still wasn’t perfect. I wanted my class to be intelligent enough to accept all valid Top Level Domains (there’s 267 in use) but reject any invalid attempt to pass as a valid TLD. IE: egypt.eg should pass, but breakfast.egg should not. The solution ended up being storing all the TLDs in a Vector and parsing through them to check if the domain was valid.

All in all the class now does a pretty good job, although there are probably still holes in it (let me know about them when you find them).

Check it out and grab it below, and then post a comment explaining to me slowly and carefully that I can achieve this exact functionality with the

1
String.giveMeAllTheURLs();

method or something similar, which I’m sure is what will happen. ;)

The code is freely available here. I would appreciate any credit and that you share whatever improvements you make with me and the rest of the world, but I have neither time nor energy surplus to actually do any enforcing, so knock yourself out.

14 Comments