3/12/2009
No no. I’m not about to start a kerfuffle about changing the location and / or name of my blog again. I just wanted to make sure you’ve heard about the new ria.creuna.com site.
Basically me and the other RIA-developers broke out and started our own blog. If you like the code, geek and tech content from this site you should be sure to check it out. For example you could start with my huge post about URL Recognition, or you could read how my co-worker exposes the clickTAG sham for the lousy stinky piece of bad stuff it is.
6/06/2009

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 »
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.
11/12/2008
A while ago I was doing a talk on the Flash platform for NRK, and to give the audience a bit of perspective I took a trip down memory lane and dug up some real goodies. Oh yes.
Since this is too good to not to be repeated, allow me to present; the Macromedia ShockZone site from 1997:
Oops. Seems you don’t have Flash Player installed. Click
here to fix it.
Click to start, or witness the fullbrowser glory.
24/09/2008
I realize that I’m late to the party with this, but so far all the examples I’ve seen have been a bit overkill for my needs, so I’m putting this out there in case someone else might have some use for it.
Of course,
is a Flash developers best friend. Hell, I sometimes feel I’d be happier if I never had to go beyond the output panel, but that’s neither here nor there. The trace statement however, as beautiful as it may be, doesn’t help you a lot when you’re debugging the project in the browser, and therefore Adobe created
to let you output the traces to Firebug. But calling
1
| ExternalInterface.call("console.log", args); |
every time you want to output something is a pain in the ass, and going through your code to change all your trace calls to ExternalInterface calls is an even bigger pain in the ass, and therefore developers created various methods to ease the pain. Here is the very lightweight solution I use myself.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| package no .martinjacobsen .utils {
import flash.external.ExternalInterface;
public class XTrace {
public static var enabled:Boolean = true;
public function XTrace (){ /*...*/ }
public static function log(...args :*) : void {
if(enabled == true) {
if(ExternalInterface.available){
trace("ExternalInterface is available")
for (var i :uint = 0; i < args .length; i ++){
ExternalInterface.call("console.log", args [i ]);
trace(args [i ]);
}
} else {
trace("ExternalInterface is not available")
for (var j :uint = 0; j < args .length; j ++){
trace(args [j ]);
}
}
} else {
trace("Set 'XTRace.enabled = true;' to enable traces.");
}
}
}
} |
As you see this class simply checks whether ExternalInterface is available, and if so traces the output to the console. If ExternalInterface is not available the statement will just be traced. As a bonus you can also set
to disable all traces if you don’t want to go through your code to remove traces, or go into the publish settings to strip them out.
Usage is extremely simplistic:
1 2 3 4 5
| import no.martinjacobsen.utils.XTrace;
XTrace.log("Hello World", 42, false, myObject);
XTrace.enabled = false; //Disable all traces |