Archive for July, 2009


Flex API bug

I just ran into an issue that looks like a bug in the Flex API. The DragManager is used for dragging and dropping between flex components, and it can also be used to implement drag and drop quite easily in your own projects. It’s (mostly) well implemented and the syntax is straightforward. To start a drag, use DragManager.doDrag(dragInitiator, dragSource, mouseEvent). The details are explained in the documentation.

The bug I encountered is in the dragSource part of the call above – it’s an instance of  DragSource class, used to store data being dragged. You add data with myDragSourceInstance.addData(myData, “identifyingString”). Nice and sensible. The problem occurs when data is retrieved through myDragSourceInstance.dataForFormat(“identifyingString”). It returns Object as data can be of any type. Here’s the method from DragSource:

public function dataForFormat(format:String):Object
 var data:Object = dataHolder[format];
 if (data)
   return data;

 if (formatHandlers[format])
   return formatHandlers[format]();

 return null;

But if the data you added is numeric zero – 0 – the test if(data) will return false and the method will return null instead of numeric zero. Bummer! I suspect that if (data || data === 0) would be better.

The workaround I used was to set data as a string instead. As data return is untyped, we need to cast it anyhow.

What do you think? Has Adobe implemented the method correctly or is this a bona fide bug?


Flash on the Beach

We’re sending three people to FotB this year. It’s our first time at the conference and we’re going mostly due to the recommendations from friends and colleagues who’ve been there before.

Very much looking forward to great sessions with all the flash-sphere names and getting to know others who work with flash. Coincidentally, Papirfly went to Brighton this winter for three days of work on strategy and products. Due to inexpensive flights and proximity to Gatwick airport, going to Brighton ended up costing about the same as staying at a hotel in Norway. Fortunately, we blew the savings on a day of racing at the Goodwood Motor Circuit! Brighton’s a nice, friendly city that I’m looking forward to visiting again and I hope to get to know the flash community better.

See you in September.

Flasher in a classic Porsche

Flash developer in a classic Porsche at Goodwood