Note: This is the old blog for rhjr.net. The new one is here.

Trace utility

Last week or so I blogged a widget called
DebugIt, which enables you to debug your Flash apps outside of the authoring environment. Today, I stripped down DebugIt to create a second debugging tool, this time in the form of a very simple ActionScript 2.0 class.

Here's the code:

class Trace {

public static function write(arguments):Void {
// Trace each argument on its own line
for (var i = 0; i < arguments.length; i++) {
trace(arguments[i]);
}
}
}

This class simply extends the capabilities of the trace() method we all know and love. Instead of allowing only one paramater, or concatenated parameters, my Trace class accepts multiple parameters and traces each to its own line in the Output panel. To use it, import the class like so:

import Trace;

Then, whenever you want to trace something, call the write() method like so:

Trace.write(args);

For example, if you'd like to trace the values of three variables, pass all three of them to the write() method.

var var1:Number = 1;
var var2:String = "Eep";
var var3:Boolean = true;

Trace.write(var1, var2, var3);

This traces ...

// 1
// Eep
// true

Simple as that. Again, this only works within Flash (the authoring environment). If you want to trace values outside of Flash, use DebugIt.

Download the Trace class.

Life-altering moments

So ... my wife and I had heard a couple of weeks ago that there would be a couple of professional pool players at SixShooters (our usual pollhall) holding some sort of exhibition event, where they would do trick shots and such. And apparently there would be an opportunity to "play the pro". I was pretty excited about the prospect of playing a pro, particularly
Helena Thornfeldt, whom I'd seen on TV many, many times, in major tournaments. I've seen the woman beat Allison Fisher, who is the #1 ranked player on the world. Helena Thornfeldt is currently ranked 6th in the world.

So we went (it was yesterday). We played for a couple of hours, and I wasn't playing well. And the pros came and set up and did a trick shot exhibition and showed off some drills you can do to try to improve your shot-making abilities. All very cool stuff. After that, another woman took sign-ups to play the pros, and I was sixth on the list. Basically, each of the two pros took a table and played whoever was up on deck. So after I signed up, I went back to my table, lined up a bunch of easy shots, and just shot them in one after another, just to get in the groove of making balls and get my confidence level up. Hey, it's not every day you play a pro. I was sure I'd get my ass kicked, but I wanted to at least make a statement. I wanted to at least get off a good shot or two.

After a few minutes, they called my name to say I was on deck. Apparently the pros had gotten through the first few racks rather quickly (as to be expected). They were winning left and right, and without much effort. Afterall, they're professionals. If you let them get to the table, they're going to run out. I had noticed that they were letting the non-pros break. I had guessed they would do this. If they didn't, no one would have played. So I stood next to the table Helena Thornfeldt was on and waited my turn. Both pros were playing games, but Helena's was going to finish first. Good. I really wanted to play her. I even shelled out a few bucks to buy the cue ball we would use during the game, and that she would sign afterwards.

She finished up that rack, winning yet another game, and it was my turn. I introduced myself, shook Helena's hand and said, "I'm a big fan." She racked up a game of 9-ball, my personal favorite, and I dropped the house cue ball into the corner pocket, replacing it on the table with my brand new rock. Then I chalked up my cue and stepped up to the table the way I had a thousand times before, and prepared to break.

I got comfortable, and shot that rock, nice and hard, straight into the 1-ball. It was a textbook break. The rack's wing ball (the 4-ball) flew right into the corner pocket, just like it should, the cue ball came back up-table, out of the way of everything else and avoiding unwanted kicks, and when everything settled into place, I had a clean, open shot on the 1-ball into the side pocket. Nice. Helena noticed. She said, "Nice break." And she sounded sincere. This from a woman that is nicknamed "The Sledgehammer" because of her incredible break.

So I moved into place and softly tapped the 1-ball into the side-pocket. Because of the angle, I was left with a long, straight-in shot on the 2-ball (heading towards the corner pocket), but I knew that would happen before I pocketed the 1-ball. Fortunately, right before I stepped up on deck, I had made about three of these types of shots in a row, and was feeling pretty good. So I lined it up, popped the cue ball solidly into the 2, and watched as the rock stopped dead in its tracks, just like I wanted it to, and the 2-ball rocketed right into the corner pocket.

I had studied the table layout. That 2-ball was the key shot. It was the only tough one on the table. And immiediately after hitting it in, I had a small moment of insanity. I thought to myself, "Wow. What the hell am I doing? Who am I to be making a shot like that against Helena 'The Sledgehammer' Thornfeldt?". But it passed, and I focused in again on the next shot. Leaving the rock in its place gave me nice position on the 3-ball. So I took a moment to line it up and tapped that in as well, being sure to leave the rock in a good spot for the 5-ball. Then I pocketed the 5-ball.

At this point, and it may have been rude as it closely resembled trash-talk, I said to Helena, "Wow - I'm not leaving you much to do." She laughed and replied about she hoped she'd get a shot.

Then I pocketed the 6-ball and left myself a difficult, but make-able shot on the 7-ball. At this point, I had just gone on the first 6-ball run I'd had all day, and I was actually starting to believe I might just clear the rack. But then I just slightly over-cut the 7-ball, it came off the rail next to the corner pocket, bounced off the other rail, came back towards center table, and rested.The cue ball was down-table a bit of the 7, and I'd left Helena with a shot that was, simply, not too pretty.

"I guess you're gonna get to shoot after all," I said.

"Yeah, but it's not a hanger by any means", she replied. It's true. I left her with a tough shot, but I was sure she could make it.

I stepped off to the side to let her do her thing, convinced I was now going to just stand by and watch her run out. I was fine with that. I had done my job rather well. I gave that woman a run for her money. I felt good.

She missed the shot on the 7-ball. And she left me with almost the exact same shot, going the other direction. I was surprised by this. I thought that if anyone could make that ball, it would be her. But I had to focus. I had a second chance at the table, against Helena "The Sledgehammer" Thornfeldt. That doesn't happen every day.

I took my shot at the 7, but I did roughly the same thing she did, and it just missed the pocket. I watched the 7 fly around the table a bit, and watched the cue ball land in a nice spot for Helena to pocket it, but not without problems. The angle wasn't great. She pocketed the ball anyway, and I thought, again, that I was done.

She had two balls to go, but the bad angle on the 7-ball left her out of line for the 8-ball. She made the 8-ball anyway, but again was left out of line for the 9-ball. And in 9-ball, the 9 is the only ball that matters. The rock sat in the center of the table. The 9-ball also sat in the center, a little down-table of the cue ball. I've faced this shot many times, and the hardest thing to do is to make the object ball without scratching. You can shoot the ball into either corner, but the cue ball has a tendency to go right into the opposite corner. This shot takes some real cue ball control. As I was thinking about this, Helena lined up her shot.

She shot the 9-ball toward the bottom-right corner, and it dropped smoothly into the pocket. The cue ball drifted off towards the other corner, as I thought it would. It was rolling slowly enough that I thought it wouldn't get there. And that rock took it's sweet time, rolling casually, like a stroll in the park on a Sunday afternoon, until it finally came to a stop. It fell into the corner pocket.

I won the game.

The crowd, who's presence I suddenly became aware of, made a collective "Oooooh" sound. They were quite surprised to see that I had stolen a game from one of the best players in the world. Hell, so was I. It's just about the last thing I expected to see happen. I said as much to Helena, shook her hand again, and thanked her for giving me the opportunity to play her. I also let her know that this game produced the first 6-ball run I'd had all day, and that I believed the nerves did something to me. I believe they made me focus like I hadn't ever focused before, and that helped my game. She related by telling me that it was always like that in pro tournaments. If you don't step up and dominate right at the beginning, it's hard to get it back. She also told me that Johnny Archer, Player of the Decade in the 1990's, is a friend of hers, and though not many people make her nervous, he makes her nervous. He makes her very nervous.

I picked up my cue ball and asked her to sign it for me. She signed it, "To Robert, Keep shooting! H.C. Thornfeldt". She told me I played well, and again sounded very sincere.

I won the game. But what's more important is that I played so well in front of 100 people. And what's even more important is that I stepped up, tried my best, and made a statement. That, and a little luck, will take you very, very far.

As I walked back towards my table, one of the poolhall regulars stopped me and extended his hand. I shook his hand, reflecting for just a moment on what had occured, and said, "I'm gonna go have a heart attack now."

AJAX: Not about technology at all

The term "AJAX", which stands for Asynchronous JavaScript and XML, has caught the Internet world by storm. Roughly four weeks ago, renowned user-experience guru Jesse James Garret (
jjg.net) wrote an article defining AJAX and effectively coined a term that became a standard faster than any of us could say, "Asynchronous what now?"

Something has been bothering me about the hype surrounding AJAX since I first read the article, and bothers me more and more every time I hear someone starts discussing it. So I'm taking the opportunity to articulate the issues and try to clear up some misconceptions.

First, AJAX is defined as an approach to web development. Nothing less, nothing more. It is not a new technology, nor is the technology used in AJAX applications anything we haven't seen before. It involves, primarily, JavaScript, HTML, and XML. AJAX applications will also likely encompass some CSS. In other words, anyone experienced with DHTML or JavaScript has probably already been using the essential ingredients of an AJAX application for a long time.

That said, the applications cited as prime examples of AJAX development - things like Gmail and Google maps - do have a common thread, and it's not the technology. What links these mind-altering applications together is not JavaScript. It's the user experience.

If you doubt this, consider the source of the acronym. Jesse James Garret is the author of "The Elements of User Experience" and the creator of a single-page PDF by the same name that often serves as the defining document for the entire development process utilized by major companies. Garret's primary concern is the user experience, and he wrote an article about the technology. Why do you suppose that is? Because he wants more people to step up and try to emulate the good practices put forth by Google.

Yes, Google used Java Script, probably some XML, and perhaps even XMLHTTPRequest (one of the core elements of AJAX applications), but that's nothing new. There are a million applications like this on the web, and we've all been using them, or some lesser variations of them, for years. What Google did was use these elements to provide a superior user experience. AJAX did not make Gmail great. The people at Google made Gmail great. Knowing JavaScript does not make you a good experience designer. Research, dedication, know-how, and time make a good experience designer, and Google has a house full of them. But the AJAX approach almost compels developers to try to follow Google's lead and create better experiences. Hence, the seedling that became the acronym of the year.

This point was brought to light nicely at last night's user group meeting. The presenter used a location-chooser widget as an example of how AJAX might be put to use. The widget featured two dropdown menus, by which you choose your city and state. Choosing a location from one of the menus filtered the options available in the other. So If you chose Arizona as the state, the City menu offered only cities located in Arizona. And it did so without refreshing the parent HTML page. While this was certainly a decent enough example of the technologies used with AJAX applications, it was a much better example of providing a good user experience. Creating menus in this way is simply good sense. If Boston is not located in Arizona (which it's not, by the way), don't show it as an option in the City menu. If you can supply the data to the page without forcing a page refresh, it makes sense to do so, because it improves the user experience by avoiding the need to clear the screen momentarily (as a page refresh always does) and reload it with new information (this creates a cognitive disconnect).

Second, the comparison between the AJAX approach and Flash has been questioned quite a bit in the past several weeks. So be aware of the differences. AJAX has its pitfalls, just like everything else. For example, although JavaScript may have a higher compatibility rate than Flash Player 6, and a much higher compatibility rate than Flash Player 7, JavaScript has been implemented differently into every browser on the market. You cannot build an AJAX application and expect it to work everywhere. Accomplishing this goal, if it's even possible, takes a lot of work. Flash, on the other hand, is cross-browser compatible, cross-device compatible, and in many cases even cross-OS compatible. Build it once, deploy it anywhere. Modifications, if required, are for the most part trivial (small screens and intermittent network connections can, and likely will, affect your application when ported to devices).

Now, to be clear, I am not saying any of this as an attempt to derail the hype over AJAX. To the contrary, I think that AJAX applications could be the best thing to happen to the Web in years. But not because of the technology. Rather, I'm excited because AJAX applications, apparently, are making developers do things that improve the user experience without really having to think about the user experience. So developers can go on believing they're just developers, and leave all the XD (experience design) stuff to the experts. XD experts, on the other hand, finally have a glimmer of a hope that developers will finally start implementing some good usability practices without being forced into it.

Sounds like a win-win to me. Go Jesse.

DebugIt 1.0

We all know there are limited options for debugging Flash applications. The trace() command only allows one parameter (unless you concatenate them), and when running applications outside of the Flash authoring tool, we don't even have the luxury of using trace(). So we're left creating dynamic text fields on the stage to display information. It's not clean, it's not fun, and it's very easy to forget to remove the debug code. My answer to this is my newest extension, DebugIt 1.0.

DebugIt comes in two pieces: a component and a SWF.

The first piece is a component. Simply drop the DebugIt Sender component into any FLA you plan to publish for Flash Player 6 or higher. Then, call Debug.write(args) in your ActionScript, instead of trace(). Yes, it's a little more verbose than trace(), but with it, you get the following benefits:

1) You can pass more than one parameter in the method call. For example, calling "Debug.write(var1, var2, var3)" will display the value of each of the three variables in DebugIt Receiver, each on a new line.
2) DebugIt supports cross-domain communication, so you can debug applications outside of the Flash authoring tool, across multiple domains, before, during, or after deployment.

The second piece, as you may have guessed, is DebugIt Receiver. Run DebugIt Receiver (a SWF) at the same time you run your Flash application. The data you requested from your application will display in DebugIt Receiver.

It's as simple as that.

Download DebugIt now.

P.S. There's definitely room for DebugIt to grow, and I plan to keep adding water until it's all grown up. If you have suggestions, contact me.

TypeIt4Me for Mac is the best thing ever.

You heard me right. "TypeIt4Me", a Mac-only shareware app that costs a reasonable $27, is the best thing ever. Wanna know why? Because it's a tiny app, that runs all time, that does nothing but expand whatever abbreviations you set up into full words or terms.

To start out, I set up all the basics. For example, I set up an abbreviation for my name. Now, whenever I type "_name" and hit the spacebar, in any Mac application, the text changes to "Robert Hoekman, Jr". And when I type "acs2", the text expands into "ActionScript 2.0". Pretty handy. But then I started to imagine writing ActionScript in shorthand, and that's when things got fun.

First, I set up a few abbreviations for oft-used keywords or script phrases, like "function" and "= function (){". You know, all the things I have to type 100 times a day. This immediately saved me a ton of keystrokes.

And then I just went crazy. I set up an abbreviation that creates an ActionScript 2.0 class. I type "newclass", hit Return, and the abbreviation turns magically into this:

/* @ author: Robert Hoekman, Jr.
* @ last modified: 3/19/05
* @ purpose:
*/

class MyClass {

// Class Properties
var myVar:String;

// Class Constructor
function MyClass (){

}

// Class Methods
function myFunction (){

}
}

Just like that, I've got myself an entire class, ready and waiting to be saved. (Of course, I first replace the class name and such with more applicable and logical names.)

This may be the closest we'll ever get to having a Snippets panel in Flash (until I build one myself), but it'll do just fine. I'm lovin' this thing and I've only had it installed for an hour.

If you're a Mac user,
download and install TypeIt4Me right now (free for 30 days).

// rhjr.net adds Google Free SiteSearch

It's really been bothering me that my site didn't offer a search method to visitors, so
Google SiteSearch has been implemented. It now appears right above the persistent navigation in the sidebar on every page of my site. Happy Googling!

It's not a bundle - it's a bad customer experience

John Dowdell (Macromedia) has been begging the masses over the past several days to stop screaming "bundle!" in response to the Yahoo toolbar/Flash Player package offer on Macromedia's web site. John's comments have gone unheard for the most part, because the initial reaction to seeing the Yahoo offer on the Flash Player download page (Win/IE only) was that it looked like a bundle and smelled like a bundle, so it must therefore be a bundle. And bundles are baaaaaad.

Here's the scoop: John is right. It's not actually a bundle, and everyone knows it. But yes, it does look and smell just like one. And that's been my main argument. I've been playing devil's advocate by arguing that no one cares that it's not a bundle, because in this case, appearance is all that matters. Again, it looks and smells like a bundle.

Macromedia may be contractually obligated to maintain the opt-out mechanism on that page. If so, there is no point in debating it anymore.

There is, however, still a serious need to revamp the user-experience provided on that page. The experience, after all, is what's making this offer look like a bundle. If the page design more clearly reflected the seperation of the two products, and made it painfully obvious that the user needs to opt-out if he/she does not want the Yahoo toolbar, my fears for the fate of the Flash Player would decrease. (I'll still be nervous about future offers coupled with the Flash Player, but at least I'll feel better about this particular snafu).

The fact is that users who hit the download page are looking for exactly one thing: an "Install" button. So what will make the user see the Yahoo toolbar offer and decide whether or not to opt-out?

Two buttons. One that says "Install Flash Player Only" and one that says "Install Flash Player and Yahoo! Toolbar".

With two buttons, users would be forced to look at the page instead of just clicking whatever default option exists. The user would then have to choose which button to click.

Yes, this means there would be more than one "banana" (read the "Big Red Fez" by Seth Godin to understand the reference) on the page, but this approach would dramatically decrease the odds of someone unknowingly installing the Yahoo toolbar.

So, that's my suggestion. If you agree or disagree with this idea, or have your own, please add a comment to this post. Macromedia is reading my blog, so they will hear you.

Message from David Mendels about the Yahoo toolbar/Flash Player train wreck

A little googling revealed
this blog comment from David Mendels (from Macromedia).

I, for one, am very glad to see Macromedia showing some humility and working towards a better solution.

We'll see what happens, I guess.

Flash Player/Yahoo toolbar controversy hits Slashdot

Absolutely amazing. Grass-roots protesting can apparently go a long way when you do it online. The controversy over Macromedia's Flash Player/Yahoo toolbar bundling has hit
Slashdot.

For the next week, I'll be gathering facts to support the case against the decision to bundle the Yahoo toolbar with the Flash Player (John Dowdell from Macromedia has asked for this), and I'll be looking for your help.

Please, start writing a list of anything you can think of - hard evidence that this is a bad decision - and tell me about it.