Posts in Category "Uncategorized"

flashlog.txt

‘ve been working on some code that has made it difficult to use the normal FlashBuilder based process of running in debug and using the step through debugger. This has me spending a lot of time reading through the flashlog.txt file that the debug player output. I also spend a lot of time seeing the dirty secret trace output that every single SWF on the net seems to belch into the log. On a whim, I wrote a script to switch the logging on or off. If you do much work with scripting or sed, this is pretty basic.

sed -i '' 's/=./='"$1"'/g' /Library/Application\ Support/Macromedia/mm.cfg

Put that in a file (such as ~/bin/setFlashLog), make sure you have execute permission, then just type ‘setFlashLog 1′ or ‘setFlashLog 0′, depending on how you want your logging (on or off).

Not being happy with that, I wrote an even more elaborate script to toggle the setting to the opposite of whatever it’s set at now:

read -r FIRSTLINE < /Library/Application\ Support/Macromedia/mm.cfg

len=${#FIRSTLINE}
idx=$(($len - 1))
value=${FIRSTLINE:idx}

if [ "$value" == "1" ];
then
sed -i '' 's/=1/=0/g' /Library/Application\ Support/Macromedia/mm.cfg
echo "flash logging: off"
else
sed -i '' 's/=0/=1/g' /Library/Application\ Support/Macromedia/mm.cfg
echo "flash logging: on"
fi

As with all things *nix, there's probably about 12 other ways to do this. However, since sed was the current favorite hammer, that's what I used to pound the nail. Note that you need the debug player for anything to show up on the log. Also note that the player checks this setting at the time a SWF is loaded, and outputs accordingly. Once the SWF is running, a change in the setting will have no effect.

Craftsmanship, Priorities, and Agile

In Adobe Professional Services, we are big on software craftsmanship. We are committed to clean code, T.D.D., the SOLID design principles, and the idea that craftsmanship will increase customer value. This is not always an easy crusade to be part of, largely due to the fact that our work is usually beholden to the needs of our customer. There are many cases where the customer may make demands that suggest we compromise our standards. For some, this is a cry to battle, and the ensuing tension can make a project troubled, to say the least. There are times when this seems to come down to an ‘all or nothing’ stand on quality, with ‘push back’ being the war cry of developers. I feel this is a common pattern in the software industry, but extreme stances are never a good way to get things done. This is where Agile comes in.

Agile is the rule of the land in Professional Services (and across many product teams at Adobe). There is an important aspect of Agile that may help move things away from an all or nothing dialog around the inclusion of quality in delivery. In general, Agile can be seen as guidelines for achieving balance. In Agile’s very definition, the things that are ‘favored’ (individuals, interactions, working software, collaboration, response to change) are just that; favored. They aren’t strictly demanded, and there isn’t a formula for measuring the percentage of implementation. Problems come when any one principle is ‘favored’ more than another. In this case, the ‘commit to technical excellence and good design’ principle of Agile can be taken to an extreme, while the customer may be taking ‘deliver working software of business value’ to their own extreme. If either principle becomes a goal in itself, this begins to limit the inclusion of other, equally important goals.

The frustrating thing for developers, especially those committed to quality, is that business value should ultimately be decided by the customer! In the end, we should strive to provide quality as a rule, but the customer keeps the lights on, so delivery should take precedence. If the customer is not giving enough allowance for quality, one approach is to help them see the business value of quality, rather than simply pushing back. However, Agile provides other ways for developers to shield themselves from focus moving too far toward delivery.

Another principle is the idea of “maximizing simplicity”, which is measured by the amount of work *not* done. Delivery of working software is supposed to be the *only* measure of progress. However, a good team can work within that definition to provide an adequate balance between value, architecture, and quality. Craftsmanship, pragmatically applied, is non-negotiable. The point of balance is to be doing just enough, while not becoming and end in itself. This is the same principle behind stories being a seed, rather than detailed requirements, and the deferred design that comes in sprint planning. The ‘just enough’ idea should be able to provide some padding for the dev team, so that quality doesn’t have to be completely dropped in the face of delivery pressure.

In the end, the tension between customer and developers is probably a good thing. A team with out constraints may tend toward over-architecting, and a customer with no technical resistance is likely to create low quality software. For me, a big selling point of Agile is how the principles work together to make life better for both development and the customer.

One Application, Four Frameworks, and All the Code You Can Eat

I’m bummed I didn’t get to attend MAX. One of the things I’m sorry I missed was Christophe Coenraets’ session on Flex frameworks. The ‘which framework’ debate has heated up over the last few years. Being so busy at work, I don’t always get the time I’d like to explore some of the offerings.
During Christophe’s session, there was fairly direct comparison between Cairngorm, PureMVC, Swiz, and Mate. It’s an ambitious and long over-due exercise. I’ve seen some attempts to compare members of that crowd, but the result rarely came across as a direct comparison, and it was rare that the result was useful as a reference. From Christophe’s description, this seems to be the most fair and complete comparison done so far. Considering the code was written by people with a fair investment in each framework, it’s about as good as your going to get.
Check out Christophe’s blog entry that covers the results of the session. Definetly don’t miss the source code, which provides reference apps built with each framework.
Great stuff, really. This is just what an aspiring project architect needs to make an informed decision about which framework or practices best fit the problems they are addressing.

Adobe AIR 2 at MAX

There is some great stuff going on at MAX. Being primarily focused on AIR development, I might be biased in my excitement over the AIR 2 announcement.
Highlights include an updated version of WebKit, support for interaction with native OS processes, multi-touch gesture support, improved socket support, and more. With all that, it’s hard to say what is most exciting. WebKit will add speed, for sure. The native process API opens up a lot of possibilities, as does better control over socket layer connections. While there are not a ton of touch screen devices available, people are getting more used to the idea of multi-touch gestures, so working them into applications will become more common. In all, some cool stuff to think about.
AIR is already proving a useful platform, but with these additions there is a lot more potential. I’m excited to get some time to check out the new features!
More details are posted in the AIR Team Blog.

Adobe Open Soure: FlexPMD

A few of the team in Adobe Professional Services have been working on a port of PMD to work with ActionScript.
From the overview:

FlexPMD is a tool that helps to improve code quality by auditing any AS3/Flex source directory and detecting common bad practices, such as:

  • Unused code (functions, variables, constants, etc.)
  • Inefficient code (misuse of dynamic filters, heavy constructors, etc.)
  • Over-complex code (nested loops, too many conditionals, etc.)
  • Over-long code (classes, methods, etc.)
  • Incorrect use of the Flex component lifecycle (commitProperties, etc.)

A report is produced describing the violations of a given rule set. FlexPMD includes a rule set that is broad ranging and continually growing.
We have been using this on my current project, and it’s a great tool. Especially handy is the ability to edit or create the rule set. This also integrates well with continuous integration tools, providing updated reports ever time the build scripts run.
Check out on Confluence, the Adobe Open Source website (you may need to log into Adobe to view the link):
http://opensource.adobe.com/wiki/display/flexpmd/FlexPMD

XD blog – Adobe on Adobe

The XD (experience design) group at Adobe has unveiled a new, flex based ‘blogazine':
xd.adobe.com
There is an interesting video about the motives of XD in creating the blog, with a lot of focus on their motives to break out of the traditional blog structure and explore using various Adobe technologies in their new design.
They also mention guest speakers, interviews, and behind the scene insight into the world of XD and the evolution of Adobe’s products and technologies. There’s a lot of strong feelings in the wild about the Adobe experience. Having a closer look at the process involved in determining the evolution of the Adobe experience should prove interesting for all the followers of Adobe.

AIR 1.5 Cookbook

AIR 1.5 Cookbook cover - image by O'Reilly Media
David Tucker
Marco Casario
Koen De Weggheleire
Rich Tretola
ISBN 10: 0-596-52250-9 | ISBN 13: 9780596522506
Monday was the official print release of the O’Reilly AIR 1.5 Cookbook, which Ikezi and I worked on as technical editors. It was available at MAX for sale, but still is on pre-order in the US and UK on the O’Reilly web site. The book features examples for Flex and HTML/Javascript development of AIR applications, and covers a range of topics, from the basics to get someone started, to advanced techniques that put the power of the AIR platform to work.
The final list of chapters should enumerate the variety of skills this book can help you grasp:
1. AIR Basics
2. Application Settings
3. Application Windows
4. Screens
5. HTML Content
6. PDF Support
7. Clipboard Support
8. Drag and Drop Support
9. File System Integration
10. Embedded SQL Database Programming
11. Encrypted Local Store
12. Application and Window Native Menus
13. Taskbar and Dock Integration
14. File Types
15. Service Monitor Framework
16. Application Updates
17. AIR Application Distribution with the Browser API
18. Developing Mashup AIR Applications – online bonus chapter
On Adobe’s DevNet you can find all the resources you need to get started with AIR, including a chapter excerpt from the book. There is also a bonus chapter available through a link on the O’Reilly web site.
The code examples (which I have gone through in detail, trust me) are concise and helpful. Even if you are relatively new to ActionScript, Flex, or HTML and JavaScript, you should be able to easily follow this book and learn how to make your own AIR applications.
I enjoyed working on this, but would offer one insights to anyone thinking they want to be a technical editor. It was a lot more work than I thought it would be. However, since being a tech editor brings fame, groupies, and membership into an elite circle (the lucky few to have 3 sentences of recognition published about them in an O’Reilly book), I’d probably do it again.

MAX 2008, the VPN, and nerd joy

Mac users: did your VPN client quit on you recently? Read on, then. I have suffered a similar fate, and found a potential remedy, which I am glad to share.
I have been lucky enough to attend MAX this year, but have not blogged a single peep about it. That’s not because MAX is terribly dull, with no great announcements, code insights, or geeked out super nerds with kilts playing Unreal Tournament on bean-bag chairs. Ho, no. There’s been a ton of that. Sadly, there’s also been a broken VPN client on my MacBook.
20081119_01.png
The problem was Heisenberg quirky for a while, such that whenever I had some spare time and would attempt to fix the connection, the problem would stop occurring. It only seemed to break when I was stressed for time, working at a client’s site, and already grinding my teeth over some other problem. Luckily, if you use Google to search for ‘Error 51: Unable to communicate with the VPN subsystem’, you get two entries, one of which explains the whole thing. Note that, if you type ‘Area 51′, you will get considerably more than two results, on a topic not really related to broken VPN clients.
First, the word on the internet is “the Cisco VPN client tends to break with most OS X updates”. Like a good solider, I tend to accept OSX updates from Apple, mostly because I hope it will fix various annoying broken things. Like the kernal panic when unplugging my Apple keyboard, for example. While that issue persists, it looks like I’ve gained a new hassle by having an intermittently broken VPN. Expect the broken stopped being intermittent, as of last week, just before MAX and all the fun things I wanted to blog while sitting on a bean bag at Moscone West. So I’m fixing it.
The page continues; ‘I’ve found the Cisco VPN client to be the least reliable VPN client I’ve ever used. In fact, I think it breaks during most updates, possibly because Cisco (a) doesn’t bother to write a more modern launchd version, and/or (b) they put their StartupItem in the System/Library/StartupItems folder, which (unless I’m mistaken) is intended to be reserved for Apple software.”
The best part was finding the solution. There is nothing that delivers greater nerd joy than a shell command for punching a troublesome process in the kidney. Since the console log reported “com.cisco.VPNClient[301]: Could not attach to driver. Is kernel module loaded?”, the idea of giving the VPN driver a kick seemed worth a try. Here’s the command:
sudo /System/Library/StartupItems/CiscoVPN/CiscoVPN restart
Which I ran as such:
20081119_02.png
Type that into terminal, along with your password, and you should be up and running.
More on MAX in a bit; it’s (finally!) my turn to play some Unreal Tournament with kilt-boy.

Exporting Charts to PNG

On a recent project, we needed to export PNG images for a series of charts. Part of the design was to create the charts in ActionScript, rather than MXML. Below are code highlights of how we went about the process.
The charts were listed in a type safe enumeration. Coming from a long Java background, it’s always comforting to see an old OOP standby get implemented in ActionScript. For each chart, a representative ChartSetup class was created, that contained the specifics of the chart’s configuration, series, axis’s, etc. For each entry in the enumeration, we included a reference to each representation class, as well as a constant that declared what type of chart the class was representing.
Construction of an enumeration entry, passing in SpendingByBusinessUnit, the ChartSetup class for that chart:

public static var SPENDING_BY_BUSINESS_UNIT:ChartType = 
new ChartType(0, SpendingByBusinessUnit);

This class reference is later used during the creation of the charts. A loop reads all of the constants in the enumeration, the class representing each chart is instantiated, and the chart is added to the user interface.

for each (var chartType:ChartType in ChartType.allCharts)
{
var ClassReference:Class = chartType.chartClass;
var chartDetails:* = (new ClassReference() as ChartSetup);
var chartDisplay:*;
if (chartType.type == ChartType.COLUMN) {
chartDisplay = new ColumnChart();
chartDisplay.height = chartDetails.chartHeight;
chartDisplay.width = chartDetails.chartWidth;
chartDisplay.showDataTips = true;
chartDisplay.type= chartDetails.columnType;
chartDisplay.series = chartDetails.series;
// etc

This created a set of charts, but what about the screenshots? We needed to collect a PNG of each chart, which was sent off to be embedded in a PowerPoint template. Capturing a bitmap image of a DisplayObject is not a big secret these days. For us, the trick was all in the timing. If you capture the bitmap directly after the chart creation, you might get a blank image. This is where the ‘Update Complete’ event comes in handy. We added a listener, calling the bitmap capture once ‘Update Complete’ fired. With the listener added, the charts were placed in a UI container, for the immediate enjoyment of the user.

// chart build, add listener  
var chartBox:VBox = Application.application.chartsPane.chartBox;
DisplayObject(chartDisplay).addEventListener(
FlexEvent.UPDATE_COMPLETE, exportReady); // add to stage chartBox.addChild(chartDisplay);

Last, we needed to get the chart image captured. With a fully rendered DisplayObject, it’s not too complicated. Just create an instance of BitmapData using the DisplayObject‘s dimensions and encode with the PNGEncoder. Done!
Here’s the code:

public static function exportReady(event:FlexEvent):void
{
   // if all items are ready
   for each(var item:DisplayObject in images.getChildren())
{
screenshots.push(ChartImageCreator.screenshotChartForExport(item));
       // etc
// code snip from screenshotChartForExport ...
var bitmapData:BitmapData =
new BitmapData(displayObject.width, displayObject.height, true, 0);
bitmapData.draw(displayObject); var pngEncoder:PNGEncoder = new PNGEncoder(); return pngEncoder.encode(bitmapData);

That’s it. If your charts are strictly MXML, you should still be able to capture the PNG, by referencing the chart by it’s id attribute.

Hello World

Just a few days ago I was giving my Tech Editor biography to O’Reilly. They suggested I include a link to my blog. I explained that I didn’t have an active, all teh internets web log, because I am busy actually working. Now, look at me! I blog, therefore, I am … procrastinating? I’m all hooked up to the tubes, with Adobe.com in the URL. Wow. I promise I’ll make good use of the space. Be ready to hang on ever word. Or cringe at every word? We shall see.