Archive for 'tips'

Documenting functions and named parameters

Sometime ago someone asked me how I’d pass custom paramaters to event listeners. I don’t remember the exact use case neither who asked me but basically he was asking for something like:
mc.addEventListener(MouseEvent.CLICK, myListener, "myCustomParam", 2);
functoin myListener(event: MouseEvent, custom :String, custom2 : int) : void;
While the exact syntax above would not be possible, closures are in [...]

AS3 Package level functions and Java static imports

It’s a hidden treasure for lot of people but AS3 provides a mechanism to declare functions like setTimeout or setInterval called package level functions. These functions are defined inside packages like flash.utils.setInterval or flash.utils.setTimeout but can be used as if they were static functions.
This is a feature widely used in FlexUnit but that can be [...]

HowTo create your developer ToolBox with Mixins

In this post I’ll explain how you can develop a flex library that automatically initializes itself avoiding developers the hassle of remembering how, when and where the libraries need to be initialized and hooked into the application. This can be particularly helpful for debugging libraries like fxSpy, DeMonsterDebugger, KaptInspect, mrdoob, etc. and extremely useful to [...]

Global Exception or Error Handling in Flex

In this post I explain how you can catch unhandled exceptions or errors globally in a declarative mxml-based way using the [Mixin] flex-specific metadata tag.
Starting on FP 10.1 and AIR 2.0 you can capture unhandled exceptions or errors globally. Although you can use these new APIs you should always take care of the exceptions where [...]

Properties file based configuration mechanism for Parsley

In this post I introduce a new mechanism for Parsley to load part of a Context from a properties file. This way highly dynamic of changing properties can be managed externally from the properties file, avoiding the verbosity of an XML approach. As always, the source code is attached.
One of the things I like a [...]

String Templating in Flex

When working with String templates, code can easily become quite difficult to read and, consequently, to understand, maintain and modify. This blog post explains 2 techniques that can help you dealing with String concatenation and templating: StringUtil.substitue and [Embed] compiler directive.
For simple String concatenation like:
var value : String = "The value " + user + [...]

DualPanel Reversible Component

This week I’ve been discussing with Alberto from undefined.es different ways to implement a reversible panel. Basically a reversible panel would be a 2-sides panel. In the front part you could have the component or widget and in the back you could have a configuration panel (same concept as in the OSX Dashboard widgets).
One way [...]

Disabling Bindings on certain Views to avoid unnecessary processing time

Once a view has been created, Bindings will always be active no matter if the view is invisible or removed from Stage.
There might be cases when a View is constantly receiving Binding updates (i.e. connected to an LCDS server with big amount of data transfer or messages). Imagine the view that is processing all the [...]

Some thoughts on constructor and method parameters

I consider a best practice to keep to the minimum the number of arguments a method accepts. As uncle Bob explains in his “Clean code” book we should always favour niladic (no arguments), monadic (1 argument) or dyadic (2 argument) methods and avoid whenever possible methods with more than 3 arguments, if not possible we [...]

Using BlazeDS from a Flash or AS3-only project

Some weeks ago I had to develop a light version of an existing Flex application. The Flex application consumed lot of Java logic through services exposed by BlazeDS’s RemoteObjects.
The goal was to be able to consume, from the new application, the exact same Java Services that the Flex application was consuming through RemoteObjects without [...]