360 Flex

15 05 2007

So, it’s official: I’m going to be speaking at 360 Flex in September/October. The speaker list went up on the site today!

I’m going to be talking about something I’ve had rattling around in my head for a while: Navigation and “power user” features in RIAs, specifically Flex RIAs. They way I use my computer is not the way I can use my RIAs, and I don’t like that. I use things like QuickSilver, and Firefox Mouse Gestures, and the command line (<3 bash) and I want that experience in my RIAs too.

The talk basically asks: How do you start introducing “power user” features into your Flex Apps, and how do you start to educate the general user about the productivity gains they’ll get by making use of these types of features?

I’m really excited about being able to do this talk. Plus, it means I get to go to 360 Flex. Good times.


17 03 2007

A few co-workers, Sean Christmann, Adam Flater and I at effectiveUI have been working on a project to extend and enhance Adobe’s Apollo by connecting it with Java. Our very own Sean Christmann, demo-ed what we have so far at Apollo Camp last night. Sean, formerly a mere padawan learner is now a Jedi Knight as proved by this video. Impressive! Very Impressive…

You can learn more about Artemis here, but I’ll give a quick rundown in delicious blog form right now.

First off, the name says it all: Artemis was the twin sister of Apollo in Greek mythology. That’s the idea of the project – it sets up Apollo to work along side Java and vice versa. When both these technologies are released the experience will be as seamless as starting any other Apollo application but by using Artemis a developer can tap into the power of any Java library to do anything Java can do. Access peripheral devices, load native libraries, transform xml using xslt, connect to a database with jdbc, ect.

Think of it like this: Let Java do what it’s already good at, and let Flex/Flash with Apollo do what it’s good at. Think of how cool Java applications will look and work now that Apollo can be the front end to anything you can write in Java. Burn your Grid Bags! Everyone who’s used e4x in Flex knows how great a step forward it is, but perhaps wants something more, like xslt support – especially now that html is supported in Apollo. Java already has libraries to do that – now you can use them.

The big idea here though is the community behind the project. Artemis is also a library framework along the lines of something like a java servelet container. Developers will be able to write and publish the Java and Flex components that make up an Artemis library at the Artemis Website. These libraries will make it easy for other developers to make use of the technology I’ve mentioned and more that I’ve not even thought of. When someone needs to do something a little crazy in Apollo, the first place they’ll look is to Artemis to see if there’s already a library that makes it trivial.

Keep in mind that Artemis is in alpha, which is one step further along from pie in the sky. We’ll make it come together with your help as we get ideas for what the community wants out of it. Keep an eye on http://artemis.effectiveui.com and speak up once we get some forum action up there. Let us know the kinds of things you want to be able to do with Apollo, and as more information and tutorials become available, start making those ideas into libraries we can all use.

It’s a very exciting time. Keep in touch as we get this thing going.

Runtime class instantiation in Actionscript 3.0

1 03 2007

So, a few times now in the past few days I’ve come across someone that needed to instantiate a class in ActionScript knowing only the class’ name as a string. Here’s a description of how to do that.

In Java, it’s easy to get the reference to a class given a string of that class’ name, e.g. “com.acme.AClass”. I can say

String className = "com.acme.AClass";
Class clazz = Class.forName(className);

And I have a reference to a Class, which I can use to get an Object of that class. The only requirement is that I have that class available in the classpath. Does ActionScript have anything like Class.forName? Kind of. Here’s a simple example which actually instantiates the class:

import flash.utils.getDefinitionByName;
import com.acme.AClass;
var testObj:AClass;
var clazz:Class = Class(getDefinitionByName("com.acme.AClass"));
testObj = new clazz();

Why did I say “Kind of” above, then? As I mentioned, Java requires that the class is available in the classpath to be able to get a reference to it. ActionScript, however, requires that the Class be referenced in the code that calls getDefinitionByName(), or at least in the application that loads that code. That makes it a little harder to dynamically load and instantiate classes. It’s not enough that the class be imported, since that’s only a compile-time directive. The class must be referenced in the code explicitly, as in the line “var testObj:AClass” above. This sheds a little light on the notion of ActionScript’s “classpath”: Only classes referenced explicitly are compiled into the swf – so only those classes are available for runtime instantiation.

How do you get around that? What if you don’t know which classes you want to load while you’re developing? Well, there are some things I know you can do, and I’m sure there are some other routes available beyond those. One thing you could do is get a rough idea which classes you’ll need and, somewhere in your application, include and reference them all. This is the shotgun approach and it isn’t pretty. Another is to load a swf that you know references the classes you need. All that’s necessary is that the swf is loaded before getDefinitionByName is called. Watch this space for some other ideas, or post any approaches you’ve taken below.

PSA: Bindable Setters Don’t Fire!

13 12 2006

I ran into a strange problem in Flex yesterday, and I wanted to share it with you in an effort to make the world a better place. I found that some logic in a setter on my model wasn’t getting executed, which was quite confusing.

First of all, getters/setters are a set of functions in Actionscript (since version 2) that allow you to syntactically treat a function like a property, e.g.:

val =
objectWithoutGetterSetter.getValue(); //val=42;
objectWithGetterSetter.value = 42;
val =
objectWithGetterSetter.value; //val=42
// on ObjectWithGetter
public function set value(val:int):void {
this.val = val;
public function get value():int {
return this.val;

The benefit is readability, mostly, which is all to the good. To the world outside the object it looks like it has a property. In the getter and setter I can execute logic like in a traditional function.

There is another feature of Actionscript, Binding, that works particularly well with getters/setters. It allows me to annotate a setter as “bindable” using the [Bindable] annotation. Elsewhere in the code I can use certain language features to “bind” to that variable, getting changes automagically.

The problem is when I mark a getter/setter pair [Bindable] (works on either the getter or setter) the binding logic decides that if I call the setter with the value that the getter returns (i.e. the current value) the logic in the setter will not execute. IMHO, this breaks the setter pattern. What use is it to have a cool feature like a setter if you can’t depend on the logic in it? You may as well only bind to a traditional property and change that property through a traditional setter function.

I assume the code works the way it does because of performance: Having the whole binding chain execute when the value didn’t change may be inefficient. Perhaps there’re other reasons. Still, it’d be nice to have this behavior explicit, since I may have important logic that needs to execute even if the value doesn’t actually change. I may not know, and I certainly don’t want to have to check each time.

Forewarned is fore-armed and all that. Watch out for bindable getter/setter pairs.


Get every new post delivered to your Inbox.