Archive for the 'flex' Category


Do they test at all?

I’ve noticed that there are a lot of sites out there that have swfs throwing Errors (*).  It’s the most annoying thing about having to use the debugger version of the flash player. I don’t want to look at other coders sloppy error handling, but there seems to be no choice. Check Microsofts Xbox Live site for instance: – it pops an error window with: Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found. The site is just a random example – Microsoft is no better or worse than others. Continue reading ‘Do they test at all?’


Flash Builder wishes

Everybody wants to change the world. And every developer wants something their tools don’t provide. I’m mostly a happy camper when it comes to Flash/Flex Builder – it allows me to do my job with little fuss. And if there is something that taints the experience  I can just think of the Flash IDE – which immediately makes Flex shine again. But even so there are a couple of things that could lighten the day:

Super quick bookmarks
I need to jump around in the code when debugging or adding functionality to existing code. In venerable SE|PY, I could click once in the left hand margin to set bookmarks. In Flex I have to select text, context click and save.  Too much! I just need a quick way to navigate between a bunch of methods.

What about my parents?
Complex frameworks often entails extended classes to avoid duplicate code. But remembering in which class of the inheritance chain a method is defined can be hard. What about an option that lets you view all the inherited methods as well? In the same code view, but with colour coded backgrounds to make it possible to see at a glance where the method hails from. And with navigation to go into the actual class the inherited method was defined in. When trying to familiarise (or re-familiarise) myself with code sets, this would make the task much easier.

The Declarations and References search tools introduced in FB3 are a good idea, but they are slow and clunky. This information should be available instantly, either through context icons or context sensitive views – select a method – the content of the view changes.

Complex formulas
Formulas for placing and scaling graphic elements can grow to be quite complex – I do this frequently and so far, the only way to make it more readable is to split it up over several lines, making the steps towards the final answer easier to decipher when I have to change or debug the code six months later. At that point everything is forgotten and I have a hard time remembering what I did or why.

But why can’t the code editor show formulas as you would write them on paper? Instead of one long line suited to computers, we could view fractions as numbers above and below lines. I usually write out formulas that way on paper and ‘translate’ into code when I think I’ve got it. I found this example from TUAW: which is how achieve this on a mac. Imagine how much easier it would be to read formula-heavy code if FB could show it to us this way?



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?


DIY Flex SDK 3.3 in Flex Builder

Adobe has updated the flex SDK to 3.3 – they did so in March this year. I had assumed that this update was part of the Adobe auto updating regime – all other Adobe applications are handled, but apparently not all parts of the Flex Builder. So instead of waiting for things to fix themselves, I did it manually using these clear and simple instructions.

I was playing around with the Flex 4 betas when I saw it. Installing the Flex 4 SDK follows the same steps, but using it is a roller-coaster of weird bugs and exiting new features. I’m currently trying to get to terms with the new Text Layout Framework API. Exploring new APIs is overwhelming, but I have to say that it looks very good indeed.


Open challenge: Dynamic ContextMenu

Inspired by the very enjoyable challenge from my friends at Apt, we’re doing our own. In a recent project I needed a contextMenu which allowed the user to select the number of pictures to show in a ad template. The choices change with the size of the ad, so every time the context menu is shown, it’s regenerated first. But for the challenge, you can skip the regenereation bit.

I’ll post my solution on tuesday (2.jun)

Continue reading ‘Open challenge: Dynamic ContextMenu’


Server result, who called?

I ran into a problem the other day. We integrate our flash application with a server-side image archive, allowing browsing from the flash front-end. That means loading a tree structure and contents of all folders. We only load the structure initially to optimize bandwidth usage – data about the contents of folder is loaded when the user selects a folder. That means the first time I select a folder for this session, a call to the server is made requesting the content of that folder. A call-back function is set which handles placing the data into the dataProvider and updating the view.

So far, so good. But there was a snag – to further optimise transferred data, we only return data about the images in the folder, not what folder they are in. So the call back function has no way of telling where to put the data unless we make sure that there’s only one call for folder contents at a time. Continue reading ‘Server result, who called?’


Easy tweaking of Flex component skins

We run a dark grey theme for our Print application. This has required quite a lot of tweaking to get it right and despite using the css way of configuring and skinning all components, Adobe did not have dark palettes in mind when they designed the Halo theme.


E.g.: to get the selected and rollover color right for lists, we had to extend and hack the Activator class because default color handling mixes the theme color with white to get the different shades needed. Which look quite odd in a dark theme. Continue reading ‘Easy tweaking of Flex component skins’