Scott Mebberson

Icon

Web Technologist

MATE: Using the PropertySetter tag

I’ve never understood why many MATE developers don’t use proper getter/setter properties within Managers. I’ve just assumed it is because MethodInvoker is the preferred means to communicate with Managers. Setting an individual property on a Manager hasn’t been an easy thing to do, until now, so I wonder if that will change?

Having read through similar discussions on the forums however, I’m not convinced MATE purists will like/agree with this post, but I feel most confortable with property getter/setter properties and it has always been a common method in ActionScript.

Mate 0.8.6 included a new tag called PropertySetter and my eyes lit-up as soon as I read it on the change log. The PropertySetter tag (there’s no documentation for this tag yet) allows you to communicate with Managers by directly assigning values to a property, and using getter/setter property functions to check, manipulate and fire off other events as necessary.

Before the PropertySetter tag my EventMap used to communicate with Managers like this:

<EventHandlers type="{PreferencesEvent.BREAK_LENGTH}" debug="false">
<MethodInvoker generator="{ApplicationManager}" method="setBreakLength" arguments="{event.value}" /></pre>
</EventHandlers> 

and the related methods within my Managers used to look like this:

private var _breakLength : int = 0;

[Bindable(event="breakLengthChanged")]
public function get breakLength () : int
{
	return _breakLength;
}

public function setBreakLength (value : int) : void
{
	breakLength = value;
}

notice the use of a proper property getter function, but no proper property setter function – that has always felt so awkward to me. With the PropertySetter tag, I can now set a property in my Manager from my EventMap like this:

<EventHandlers type="{PreferencesEvent.BREAK_LENGTH}" debug="false">
<PropertySetter generator="{ApplicationManager}" targetKey="breakLength" source="{event.value}" /></pre>
</EventHandlers> 

and use proper property getter/setter functions in my Manger like this:

private var _breakLength : int = 0;

[Bindable(event="breakLengthChanged")]
public function get breakLength () : int
{
	return _breakLength;
}

public function set breakLength (value : int) : void
{
	_breakLength = value;
	dispatchEvent(new Event('breakLengthChanged'));
}

I’m not sure what the general community at large thinks? I’ve started a thread over on the mate forums to discuss it, but it would be great to hear other peoples opinions on what should be best practice.

Filed under: ActionScript, flex, frameworks, mate

Focus Booster, minimised!

We’re tossing up between a few options on a new feature for Focus Booster and we’d like your opinion.

We’ve had a number of requests for a minimised version of Focus Booster that doesn’t take up as much screen real estate. The two options are to show the remaining time or the progress bar. So, please let us know which you’d prefer!

Filed under: Focus Booster

GTD for developers

I follow GTD (Things) to organise my working life, making sure I have a list of the things I need to do. The list is updated and re-prioritised regularly. This method relieves me of a shit load of work related stress, as I don’t have to keep everything buzzing around in my head.

I use the Pomodoro Technique (Focus Booster) during the day at work, to make sure I’m productive and efficiently working through the gazillian items in my GTD list.

One of my favourite things about GTD is the 2 minute rule; if you can do it in 2 minutes, do it straight away, but if not, jot it down quickly without prioritising and get back to what you were doing.

At work, I encourage my development team to note any bugs while developing that they may not fix on the spot, so that nothing is forgotten and we know how much work we still have, post beta.

It has just dawned on me this is GTD for developers! So, this my new GTD for developers rule: if you can fix the issue within 5 minutes (a little extra time is required when it comes to development) do so, if not, note it down so that you can come back to it later based on priorities.

Filed under: GTD, general

Multiple screens in AIR

A user of Focus Booster sent through an interesting request, which is to make Focus Booster restore the window position upon subsequent loads. I can’t believe I hadn’t thought of that, and have now added it to my list of required standard functionality for AIR applications.

So, I set out to implement this feature and got to thinking about multi-screen support. Everything screen related takes place in the flash.display.Screen class. I thought there might be a simple method or property to return the current screen index a particular nativeWindow is on; but there isn’t really anything quite that useful there.

The closest thing you can get is Screen.screens which is an array containing individual Screen objects, one for each screen plugged into the viewing computer. From there, you have to implement your own routines to determine which screen a nativeWindow is on.

I wrote up a quick example that demonstrates how to determine which screen the window is on, and also how to store the window position and restore it next time the application is loaded. It’s called TwoScreens, and you can right-click to view the source (once you’ve unzipped the AIR file and installed it).

There may be a better way to do this, so post a comment if you know better ways to achieve this.

Filed under: ActionScript, air, flex

MATE: Responding to events

Recently, I embarked on a personal project to learn about the Mate Framework, which I’ve started hearing more and more about. We’ve successfully used Cairngorm in dozens of Flex/AIR projects at Enpresiv and I thought it was time to try out Mate (apparently pronounced mah-teh).

I’m glad I did, because it is an awesome framework with much flexibility making it suitable for many different types of projects. One of my favourite things about the framework is how quick and easy it is to integrate. It doesn’t force you to use all Mate concepts either, providing endless options for partial integration into existing projects that might just need a little structure.

One of the issues with Cairngorm that a lot of people have trouble with is easily responding to events/commands within a view (albeit the event that dispatched the event or not). I was happily surprised when I found out this is one of the easiest things to do within Mate, and there are two ways to do it!

Mate advocates the Dependency Injection pattern over the Model Locator pattern which Cairngorm advocates. Dependency Injection is a fantastic concept and truly promotes reusable views as the view needs no knowledge of the framework. Your view doesn’t really need to respond to an event directly, it just receives only the required or updated data it needs.

The second means for views to directly respond to events is using the Listener tag, which simply could not be any easier to work with.

I’ve worked up a basic yet focussed example on two options for repsonding to Mate events within views.

I plan on discussing other Mate features in future posts, but thought this was a great starting point as it’s the source of pain for many Cairngorm developers. Although, Universal Mind have released some extensions which make responding to events/commands within views much easier.

Filed under: cairngorm, flash platform, flex, frameworks, mate

the Pomodoro Technique

I’m always looking for ways to improve my productivity; the more I get done at work, the less work I have to wrestle with to stop from creeping into my family life.

I’ve been using the Pomodoro Technique for a few weeks now, and I’m pretty happy with the results. the Pomodoro Technique promotes working to a specific unit of time (25 minutes) with a 5 minute break in between sessions. During a session you’re supposed to avoid all interruptions to try and achieve a list of tasks (one task per session).

Two important things I learnt almost immediately are:

  1. make sure you break down your tasks into steps that are achievable within 30 – 40 minutes; you’ll be surprised how much extra work you can complete with 25 minute bursts of pure focus
  2. take the scheduled breaks (and when you do, get away from the computer and walk around, refresh your body, eyes and your mind), if you don’t you’ll be super tired at the end of the day

A positive side affect I’ve noticed is that your team can usually resolve any issues they have during the 25 minutes without your intervention (but that’s a blog post for another day).

I’ve started a side project with Gavin Keech, our creative director at Enpresiv to create a pomodoro timer, helping to implement the Pomodoro Technique called Focus Booster. We’ve had almost 1000 downloads since its launch (a couple of weeks ago) and we’ve had two official releases.

We built it using Flex 3, Air 1.5, the Mate FrameworkM, Degrafa, AS3CoreLib and BendPixels (for integration Pixel Bender filters) libraries. I’m going to write a series of blog posts on some of my learning’s along the way.

Filed under: general

About Me

I'm a web technologist living and working in Adelaide, Australia.

My Tweets

Navigation

My Older Posts