Don’t cast an UncaughtErrorEvent error

I just found this out the hard way, but you shouldn’t cast the error property of an UncaughtErrorEvent. I was doing the following in my uncaught error event handler:

1
2
3
4
5
6
7
8
9
private function onUncaughtErrorEvent(event:UncaughtErrorEvent):void {
	event.preventDefault();
	event.stopImmediatePropagation();
	if(event.error is Error) {
		log(Error(event.error).getStackTrace());
	}else if (event.error is ErrorEvent) {
		log(ErrorEvent(event.error).text);
	}
}

The problem with this is that it returns your uncaught error event handler as the last step when you call getStackTrace(). But changing your code a little will give you the real source of your error. Maybe everyone else knew this already, but I’m logging it here on my blog so I don’t forget.

1
2
3
4
5
6
7
8
9
private function onUncaughtErrorEvent(event:UncaughtErrorEvent):void {
	event.preventDefault();
	event.stopImmediatePropagation();
	if(event.error is Error) {
		log((event.error as Error).getStackTrace());
	}else if (event.error is ErrorEvent) {
		log(ErrorEvent(event.error).text);
	}
}

AIR Development for Blackberry Playbook

AIR for PlaybookI took some time to get familar with AIR development on the Blackberry Playbook. Overall it was pretty easy to get started but I did run into a few hurdles that I had to overcome to get the SDK and Simulator installed on Windows 7 64-Bit.

64-Bit Installation
In order to get the Blackberry tablet SDK and Simulator installed on Windows 7 64-Bit you must modify the installer to use a 32-bit Java installation. Luckily the support forums for AIR on Playbook is actually really good, you can see the installation tip here: Windows 7 64-bit Installation Workaround.

Debug Launch Configurations
The other issue I had was getting the Debug Launch Configurations to show up. Turns out after you install the SDK you need to run Flash Builder as and Administrator for the first time. This will complete the installation and the debug configurations displayed correctly.

Application development for PlayBook
Webcast series on AIR for Playbook Development
Free PlayBook Promotion

Yahoo World Cup Game

I don’t do many games, but I recently worked with Sapient to build a World Cup game for Yahoo. The game is a multi-player Penalty Shootout. It lets you invite and challenge your friends to matches or you can “play now” against a random player from around the world. This game has been localized for 17 different countries and languages. At the end of the World Cup Yahoo will even be give out a great prize to one of the top players in the game. There were lots of challenges in creating this game, but it was fun and the teams and Sapient and Yahoo were great to work with. Check it out!

Yahoo Penalty Shootout

Namespaces on Attributes with E4X in ActionScript 3

I recently came accross an odd behavior when adding namespaces to an attrubute using E4X. I needed to create an XML object like the following:

1
<body xml:lang="en" xmpp:version="1.0" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xmpp="urn:xmpp:xbosh" />

This XML element is created dynamically within the ActionScript code like this:

1
2
3
4
5
var body:XML = <body />;
var xml:Namespace = new Namespace("xml", "http://www.w3.org/XML/1998/namespace");
body.@xml::lang = "en";
var xmpp:Namespace = new Namespace("xmpp", "urn:xmpp:xbosh");
body.@xmpp::version = "1.0";

However, the output of the namespaces in the XML was off:

1
<body aaa:lang="en" aab:version="1.0" xmlns:aaa="http://www.w3.org/XML/1998/namespace" xmlns:aab="urn:xmpp:xbosh" />

I realize this is still valid, but the server was having issues with it. That’s when I discovered that I need to first add the namespaces to the XML element using addNamespace(). This then gave me the right output:

1
2
3
4
5
6
7
var body:XML = <body />;
var xml:Namespace = new Namespace("xml", "http://www.w3.org/XML/1998/namespace");
body.addNamespace(xml);
body.@xml::lang = "en";
var xmpp:Namespace = new Namespace("xmpp", "urn:xmpp:xbosh");
body.addNamespace(xmpp);
body.@xmpp::version = "1.0";

Hopefully this will save someone else an hour of banging his or her head against the wall.

Speaking about Flash Development on Facebook

Flashbelt 2010I’ll be speaking at a couple confirences in the next six months on the topic of Flash Development on Facebook. The first conference I’ll be at is MN.swf Camp on April 5th. This will be a short 30 minute session that will introduce the concepts around developing a Facebook application and specifically putting Flash Applications within Facebook.com.

Then I’ll be giving a much more in-depth session at Flashbelt in June. This session will actually dig into some of the details and caveats of Facebook development. Patterson Consulting has been doing a lot of Facebook integration with our clients lately and we see this as an emerging market Flash developers.

BusinessCard2.com using Flex to Distribute Business Cards

For the past few months I’ve been working with the guys over at Workface to develop their BusinessCard2 platform. BusinessCard2 is a fast growing social site that is focused on being your professional identity online. Simply go the BusinessCard2.com and enter in your contact information to create your card. Then you can embed the card on your web site or blog, you can share it on a number of social web sites, and you can even sign up for the AdCast service where BusinessCard2 will actually purchase advertising space and push your card to a number of publishers on a cost-per-interaction basis.

Continue reading

Upload ByteArray to Flickr

If you’ve used the the AS3 Flickr Library for uploading images to Flickr you know that it requires a FileReference object. Since you can only get a FileReference if you ask the user to browse to a local image on their hard drive or if you’re using AIR and just grab an image from the user’s hard drive. But what if you just want to upload a dynamically generated image from within your SWF?

Continue reading