Simpler Button Handling in Flash AS3

Back when I started coding in AS3 for Flash, I would create a separate event handler for each button. After a few revisions on these projects, I quickly realized that this was completely impractical. I found a far easier solution by creating a single onclick handler function for all the buttons, and switch based on the name of the button. Now, I share it with you.

btn_1.addEventListener(MouseEvent.CLICK, linkHandler);
btn_2.addEventListener(MouseEvent.CLICK, linkHandler);
 
function linkHandler(me:MouseEvent):void {
	switch(me.target.name) {
		case 'btn_1':
			// The code for button 1
			break;
		case 'btn_2':
			// The code for button 2
			break;
	}
}

Posted in CodeComments (2)

The Social Media Haunted Mental Institution

“A lot of people thought this dream must be madness, but we are not crazy.”
- Gloria Trevi

While implementing the Add This widget for a client, I stumbled upon a curious list. Since Add This allows companies to add their services to their widget, the list of available services has grown to a level of absurdity.

While some of the services are standards like Facebook and Twitter, Digg, or Reddit, most of the rest comprise what I call the Social Media Haunted Mental Institution. With names like BleetBox, CiteULike and Grumper, this may be one of the most comprehensive list of shattered website dreams, representing millions of lost investment dollars.

In the quest to create the next Facebook, they built a hall of madness.

So much effort, so many dreams, crushed in the stamped to create the next great social network. For example, are just the ones that start with “fav”: FAVable, Faves, favlog, Favoriten.de, Favoritus.

I know, it is far easier to criticize than to create, but honestly, Blurpalicious?

Checkout the full list after the jump.
Continue Reading

Posted in WebComments (0)

Load Your Model With Data in CodeIgniter

Much like fashion models, it seems that managing CodeIgniter models can be a little tricky. I always ended up with a massive pile of set_value() calls for each of the elements I wanted to load in. In order to ‘bosh this, I wrote this function to do it automagically.

It will grab all the variables you’ve declared for the model, then try to load them up with submitted data. Nifty.

function load_model() {
     $vars = get_class_vars(get_class($this));
     unset($vars['_parent_name']);
     foreach($vars as $key => $value) {
          $this->$key = $this->input->post($key);
     }
}

Posted in CodeComments (0)

Left On My Answering Machine

My good buddy Will Garrison (pictured left) recorded this on my answering machine. Also check his band Spirits of the Red City if you like delicious earfood.

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

On a completely unrelated note, if you can’t get your WordPress Audio Player plugin to work, don’t just search Google for “Why does my WordPress Audio Player Plugin show up blank?”, (Although that search should now lead you here … ) just check the Troubleshooting page! Apparently your header.php needs to call <?php wp_head(); ?>, and your footer.php needs to call <?php wp_footer(); ?>.

Whew, toofer!

Posted in UncategorizedComments (0)

Why You Shouldn’t Use The Yelp API

In an effort to create a local micro-search for a client, I used the Yelp API to get listings, and the Google Maps API to display them. Using the demo code, the results were almost miraculous. Yelp does a great job of returning relevant results, and blending them with Google Maps was a breeze. Yet something felt off about the whole operation.

Searches on the Yelp homepage were different than via the API. It took a bit of sleuthing, but I finally discovered the reason:

Yelp API doesn’t return unreviewed listings.

You heard that right. A search on the homepage will wield vastly different results than a search via the API because listings without any reviews don’t show up. This has something of a deleterious effect on searches which are less than urban.

For instance, when I search for “Hospitals” in a small town on the homepage, I get a big pile of them. When I search via the API, I get BBQ joints. That’s right. Since the hospitals have no reviews, and the BBQ reviewers used phrases like “The ribs may land you in the hospital, but they sure are delicious”, these show up in a search for hospitals.

It is perhaps darkly comic to consider the man having a heart attack and using Yelp to find a hospital, only to be presented with a list of BBQ restaurants. However, if you’re dumb enough to use Yelp to find a hospital, well, there you go.

So now I don’t use the Yelp API, and Google wins again.

Posted in Misc.Comments (4)

10 Seconds With Matt Lang: Episode 7

Posted in UncategorizedComments (0)

PHVsPjxsaT48c3Ryb25nPndvb18xY29sX2hlaWdodDwvc3Ryb25nPiAtIDIwMDwvbGk+PGxpPjxzdHJvbmc+d29vXzJjb2xfaGVpZ2h0PC9zdHJvbmc+IC0gMjAwPC9saT48bGk+PHN0cm9uZz53b29fM2NvbF9oZWlnaHQ8L3N0cm9uZz4gLSAxNTA8L2xpPjxsaT48c3Ryb25nPndvb180Y29sX2hlaWdodDwvc3Ryb25nPiAtIDEwMDwvbGk+PGxpPjxzdHJvbmc+d29vX2Fib3V0X2J1dHRvbjwvc3Ryb25nPiAtIDwvbGk+PGxpPjxzdHJvbmc+d29vX2Fib3V0X2VuYWJsZT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