What's new in Flash Builder 4.5 for Test Driven Development

english mobile

I love Test Driven Development (TDD), but there are some parts of it that I've found pretty painful in the released versions of Flash/Flex Builder. Given the benefits of TDD, I've chosen to grit my teeth and just bear with it. Last month I went to 360Flex, which showcased some of the productivity enhancements in Flash Builder 4.5, and I am thrilled to see that Adobe has addressed these pain points.

Automatic Class Generation

In most languages, TDD consists of writing a test, running it and watching it fail, writing code, and running it and (ideally) watching it pass. If it doesn't, keep modifying the code until it passes. In compiled languages such as Actionscript, many coders will add a step in the beginning where they write the first test before the Class under test exists. I have found this a pain in Flex 3 and Flash Builder 4, because my workflow winds up something like writing the test, knowing it won't even compile, then copying the name of the new Class. Then I'd use the New Class dialogue to create the Class, making sure to paste in the name of the Class from my Test.

Finally, I'd add the import statement so that mxmlc could compile the new Class into my test.

Flex 4.5 adds a new problem indicator that shows that something

is missing, a white question mark in an orange circle. When you see this, it means that there is a reference on that line that Flex doesn't yet know how to interpret. You'll be able to figure out exactly what by looking for the squiggly red line similar to what you see in a word processor when you've mistyped a word.

If you highlight the word and press Control+1 (Command+1 for Mac users), Flex will offer you the option of creating the missing definition. So you can create the Class definition right from the reference, no copying and pasting needed. Most of the time, Flex will even add the import statement as well.

Automatic Member Generation

By the same token, when you create a new property or method on your new Class, you can generate it the same way, by highlighting it and pressint Ctrl+1. Note that if the Class is inside a Library project, you'll still have to create the member variables or properties by hand, as this doesn't seem to work across projects as of this writing.

Refactoring Help

A lot of times I get halfway through a project and I realize that the Class really should be in a different package. One thing I hate about TDD is that it means there are way more references to a Class under test than one that is not tested. This means that you have to go in and fix the references to the Class you moved, not just in your project source code, but in all of your tests. In effect, your tests can lock you into a less than optimal directory structure.

Flash Builder 4.5 has changed all that. Just move or rename your Class, and all the references to it will update—and it won't take forever or crash Flash Builder (looking at you, Flex 3).


Flash Builder 4.5 has a lot of productivity enhancements like this, and you can get a full list here.

Changes for Running Unit Tests

When I first pointed Flash Builder 4.5 to my existing Flex 4.1 project, I couldn't figure out how to run my unit tests, because the "Execute FlexUnit Tests" menu item is now missing from the "Run" menu, and the application FlasnBuilder 4 created for my old unit tests had an error in it so that it wouldn't run. I wound up deleting those mxml files, but then I was at a bit of a loss as to how to run my existing unit tests.

It turns out that you need to right click on your Test Case or Suite and then select either "Run As FlexUnit Tests" or "Execute FlexUnit Tests." The major difference I see between these two options is that "Run As" provides a dialog similar to what you saw in Flash Builder 4 where you can select multiple Test Cases and/or Suites to run at one time. "Execute FlexUnit Tests" seems to run tests within the selected file or folder only, without offering the dialogue that would allow you to run other tests.

Once you have run a unit test from one of these right click menus, it will be available under the "Run" and "Debug" buttons in the main menu, but you can't change which tests will be run when you do this.

All in all, I see the changes in Flash Builder 4.5 as extremely positive for fans of TDD. I would like to see Adobe go a lot further, but overall this new version is a huge step forward.

Patience is a Vitrue (or something like that)

english mobile

I admit it, I have been neglecting this blog. In part, that is because I've been in the midst of some really exciting changes.

Before I get into what has been going on, some background. My husband, Steve Howard, moved all the way from the UK to Mississippi to marry yours truly. Soon after he moved here, he got a contract working for a company in the North Atlanta area, and that company extended a full time offer to him. He's been working there ever since--from Mississippi.

In June, I started a contract with Johnson Outdoor Marine Electronics, a division of SC Johnson, working on the upcoming Geonav G12, which will be released March 11. This has been a fantastic experience, and I am pleased to have been a part of it.

If you've followed my posts on InsideRIA (now DevelopRIA), you know that I have been very interested in the exciting possibilities inherent in social media for developers for a long time. So when a recruiter called me to tell me that Vitrue was looking for a Flex developer, I was interested. When I found out they wanted me to develop visual tools to allow non-technical people to create and edit quizzes for Facebook, I was hooked--I have been building these types of tools for many years, and I know this is something I can ace.

Lucky for me, Vitrue felt the same way, and they made me an offer I couldn't refuse. I will be staying with Johnson Outdoors until the release of the G12 on Friday, then I'll be starting with Vitrue the following Monday. I will miss my friends at Johnson, but I look forward to joining in on the fun at Vitrue.

Installing AMFPHP to Windows 7

english mobile

I was excited to read about the release of AMFPHP 1.9 in February, but I didn't need to install it until a couple of weeks ago, when I was working on refactoring my Lazy Loading Tree example to take advantage of Maté. I wound up burning up almost an entire day due to permission problems on AMFPHP that were difficult to track down.

It turns out that something about my setup, whether it's Windows 7 or IE 8, caused a problem with the zip file when I downloaded it. The first thing I needed to do was to go into the properties of the zip file and hit the "Unblock" button. I had no idea that the "blocked" setting on a zip file could affect what are, in effect, text files inside.

But even after I did that, I had problems with the AMFPHP files that were in subdirectories, and no matter how I changed security settings on it, I couldn't find anything that would work. It seems that somehow Windows was encrypting the folders as they were being extracted. When I extracted them on a thumb drive, it couldn't apply the encryption. When I copied those extracted files over to my WAMP installation, AMFPHP worked perfectly.

Hope this helps someone avoid blowing out a day on this.

Sample code for OOP + Timeline InsideRIA Article

english mobile

Several people asked me for code samples for my Combining the Timeline with OOP As3 in Flash that appeared on InsideRIA on April 7. So I've put together two examples, which produce a file that looks like this:



The example files do the same thing, just through different methods. One listens for the added event on the root document to start tweening the smiley faces as they are added, 10 frames apart. The other overrides the setter of the smiley face instance variables to start the tweening.


Download the source code here.

Debugging Responder Result Functions

english mobile

Lots of times when we use AsyncTokens with Responders, something will go wrong between when the call is made and when it returns. Usually if there is a problem, the fault handler will fire. Because of this, it's fairly straightforward to get information on what has happened in the fault responder function by looking at the FaultEvent's properties, such as the fault property.
But what about when there's an error and the Result handler is the one that fires? This does happen. For example, the infamous Access "Operation must use updateable query" error message in access triggers the result handler.

One of the first things I try to do when there is an error with a database call is to reconstruct the exact call that was made, so I can make the same call directly from a browser. It's not exactly intuitive where to find this information in the ResultEvent that is the parameter in the result handler, but, with a little digging, I found it.

It turns out that AsyncToken has a property called "Message," which is actually a HTTPRequestMessage. HTTPRequestMessage has a "body" property that is described this way: The body of a message contains the specific data that needs to be delivered to the remote destination. This, apparently, is a circuitous way of saying that this is the actual request object that was sent in the HTTPRequest.send() method that returned this token.

Hope this helps someone!

RIAdventure Inspiration

english mobile

So we're just back from the RIAdventure cruise/conference, and I have to say it was just what the doctor ordered for me. The speakers and attendees were all top notch, and I felt like a little sponge, soaking up ideas from them.



One set of ideas I'd just started reading about before going to the conference was blitting. In my roles as eLearning or Application developer, this wasn't something that I'd been exposed to much. And it seemed like a lot to get my head around until I saw Sam Rivello's Las Viditas presentation. He made this stuff look so easy, I thought maybe it wasn't so hard after all.



Couple that with the fact that I was inspired by Greg Burch's presentation to try an iPhone teaching app for children that needs to have performant animation (when the iPhone api is available), and suddenly this looked like something I needed to learn.



But since the main animation I was concerned with was rotating an object about a central point, the whole idea of repeatedly copying the pixels from different parts of an image seemed to be silly to me. So I came up with the idea of using a Flash Display object and rotating it once, programmatically, taking a snapshot at each rotation increment. Then each snapshot could be used in sequence.



Here's my first prototype of that concept:





Download the source code.

I'll probably write in detail about this code on InsideRIA in the near future, but the code is commented pretty thoroughly.

Flex Template Component

english mobile

This week on InsideRIA, I blogged about Flex Template components. My mandate for that blog is to talk more about ideas than showing code, but I had a feeling that someone would ask to see code on this one, so I put together an example of code that is similar to the component I show a screen shot of in that post for the curious.

The example linked to below has View Source enabled: