Since early 2006 I’ve been authoring articles as a staff writer for Community MX, an online magazine and tutorial resource. It is a wonderful journey of discovery, which I came to define whist I was teaching at Humber College: that you only truly know what you know until you teach it, or in this case, write about it.
In each article, in each tutorial I write, I discover something new about what I do, programming with Adobe Flash Platform technologies. This is primarily because I need to be writing it from the perspective of someone who does not know what I know, so I cannot assume anything except a certain baseline of knowledge vaguely defined by the scope and difficulty rating of the article. That’s the challenge of technical writing: it makes me a better communicator and a better programmer.
In August of this year, I began writing a new series to test my knowledge of Flex fundamentals, and to share certain tricks I have picked up along the way. The series is called the Flex 101 series, currently up to Part 13, with many more to come.
Flex 101: Part 1 - Introducing Adobe Flex 2
Flex 101: Part 2 - What’s New In Flash Player 9
Flex 101: Part 3 - Using Flex Builder 2
Flex 101: Part 4 - Building in Design Mode
Flex 101: Part 5 - Using MXML
Flex 101: Part 6 - Components and Databinding
Flex 101: Part 7 - Events
Flex 101: Part 8 - AS3 in MXML
Flex 101: Part 9 - Custom MXML Components
Flex 101: Part 10 - Databinding Custom Components
Flex 101: Part 11 - The Event Class
Flex 101: Part 12 - Using the Flex 2 Debugger
Flex 101: Part 13 - Declaring Events in AS3
The first few articles in the series are free, with the rest available at $4 US. I hope you enjoy them as much as I did writing them!
One of the questions that I get asked occasionally from other developers learning Flex is, “How do I make the code completion work with an external project?”
What you may be trying to do is linking to an external folder, by way of Navigator view > [Project Folder] > right-click > New > Folder > Advanced > Link to folder in the file system > [folder path]. This will indeed create a reference to a folder external to your project, or even your workspace, but it will not help Flex reference an external classpath for compilation or code completion.
For that, we need to configure an external compilation source. For this, we select Navigator view > [Project Folder] > right-click > Properties > Flex Build Path > Source path > Add folder > [folder path].
Keep in mind that for external classpath referencing to work, you don’t want to direct to an external project source folder, but the root classpath such as the “com” or “net” or other root class package, otherwise the classpath referencing for code completion in the editor will be misdirected.
This past September, a good friend and trusted colleague of mine David Stiller came to me with a puzzling debug message: the dreaded Error #2044. At the time I didn’t have much to tell him, until I encountered it myself a few weeks later. Now I just had to find an answer.
Unfortunately the Adobe LiveDocs runtime error listings are not particularly helpful in this regard. Judah’s blog post on the matter does give some additional info, but neither David or I had encountered this error because of a problem uploading a file, nor did the try-catch solution seem to fit in our case.
The solution at first glance seems simple: make sure that either the file the application is loading, uploading or the server-side script it is referencing, is actually there, and it is not corrupted. All of the above can result in a #2044 error.
But what if you want the error handled without the runtime debugger being in your face about it? In both David’s and my case, we wanted to ensure that if files referenced by application were not there or corrupted, that the user (i.e. QA person/developer) would get a nice alert popup instead of a runtime error — or worse, having the app fail silently.
You would expect that the following would handle the error:
- loaderXML.addEventListener(ErrorEvent.ERROR, handleError);
- private function handleError(evtObj:ErrorEvent):void
- // do something
But that doesn’t work. As the error implies, you need to use the IOErrorEvent class, not the ErrorEvent class.
- loaderXML.addEventListener(IOErrorEvent.IO_ERROR, handleIOError);
- private function handleIOError(evtObj:IOErrorEvent):void
- // do something
That works. But hang on, we’re not quite done. If you use a custom event bubbling scheme, as I had done in a custom MVC framework I built for a client…
- loaderXML.addEventListener(IOErrorEvent.IO_ERROR, handleIOError);
- protected function handleIOError(e:IOErrorEvent):void
- dispatchEvent(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, IOErrorEvent(e).text));
… and you dispatch an IOErrorEvent.IO_ERROR event, you also need to handle it all the way up the chain… or you’ll get the same runtime debugger error.
Once all possible dispatches of that event were handled as it bubbled all the way up through my Services and my Controller classes, my View showed a nice Alert with the error text, no debugger crashes.
So the lesson here is: anywhere you load a file, access a script, or load or upload any data of any kind whatsoever, in order to build a robust application, you can’t just think about handling the ErrorEvent.ERROR event: you also need to account for the IOErrorEvent.IO_ERROR event as well, or your application will have holes in it which may let slip by the dreaded Error #2044.
Over the years I have toyed with the concept of having my own blog to post Flash tips and tricks encountered in my travels, first as a “deseloper” in my early days, then as a hard core “developer” from 2004 onwards. I even started one in 2003, but being somewhat of a perfectionist, never quite got around to launching it. The list of things I wanted to to write about got quite large over the years, comprised of notes like this:
Blog Topic: Variable Listener - About Object.watch. Handy to keep in mind.
See this thread.
… but I never quite got around to actually installing Wordpress properly and writing about all of them. In the interim, I got a gig as staff writer or ‘partner’ with Community MX, and so all of my writing energies that were not funnelled into community forums went there for the first few years.
Recently, I looked up the idea of getting down to it and just getting ‘er done. Now that I find myself programming mainly in ActionScript 3.0 and Flex, I look up all of my old notes for blog topics and realize that writing about ActionScript 2.0 seems… outdated for me. Maybe later, when this new blog is firmly up and running with sufficient content, I’ll revisit all the old code and share the tips and tricks of AS 1 & 2 from an old-timer. :)
For now, the new site still has the same old storefront, but the inside just got a new coat of paint. ;)
Why did I suddenly decide to start blogging about my main passion, Flash? Well, first, it seemed kind of silly to be involved in the community for so many years, teaching courses, attending user group gatherings, conferences, and writing weekly articles, without also having my own blog. Until now I’ve procrastinated, telling myself there was no time in between community involvement, project development and technical writing to contribute enough posts in a blog to make it worth while for my readers, and not be just another half-hearted attempt by a flash developer to “be out there”. I also didn’t want to start a blog just to say I had a blog, posting everything flash-related that travelled through my brain just to say “look at me, I’m blogging, even though a thousand other developers have already covered this!!” :P (okay, I’m being facetious, but you get the idea)
Second, the forums on Community MX where I am a staff writer are members-only forums, and there have been some really good tips posted there that I’d like to share with the community. And I realize there are a few things I’ve noticed/used just this past year while dealing with ActionScript 3.0 and Flex that no one seems to have blogged about much, which are a little too advanced for a CMX article.
So here we are. And when and if the MXNA or other aggregators deem this blog good enough or complete enough or relevant enough to include in their list, well great, but that’s not why I’m doing this. As far as fancy blog widgets and other links, I’m still getting my feet wet once again with Wordpress after a long hiaitus, so please bear with me while I try out a few things.