Saturday 21 February 2009

Named Bindable and PropertyChangeEvent

I had an issue with using named bindables today and could not figure out why it wasn't working. I was using a PropertyChangeEvent as I not only wanted to bind to the property but also listen to the event and remove the previous value from an array (using the oldValue property of the event).
This worked:
private var _boundProperty : String;

[Bindable( "namedBindable" )]
public function get boundProperty() : String
{
return _boundProperty;
}

public function set boundProperty( value : String ) : void
{
_boundProperty = value;

dispatchEvent( new Event( "namedBindable" ) );
}
But this didn't:
private var _boundProperty : String;

[Bindable( "namedBindable" )]
public function get boundProperty() : String
{
return _boundProperty;
}

public function set boundProperty( value : String ) : void
{
_boundProperty = value;

dispatchEvent( new PropertyChangeEvent( "namedBindable" ) );
}
It turns out that if you use PropertyChangeEvent Flex is a bit picky and doesn't use it for binding unless you populate the property property! 
Like this:
private var _boundProperty : String;

[Bindable( "namedBindable" )]
public function get boundProperty() : String
{
return _boundProperty;
}

public function set boundProperty( value : String ) : void
{
_boundProperty = value;

dispatchEvent(
new PropertyChangeEvent(
"namedBindable",
false, false,
PropertyChangeEventKind.UPDATE,
"boundProperty"
) );
}
This seems a bit odd to me as just a plain event works fine with no additional properties. Anyway, hopefully this blog post will stop anyone else wasting time investigating this problem.

Sunday 8 February 2009

File Rename Tool

I have a lot of DVDs, probably over 400 or so. Quite a few of these DVDs are box sets that Linzi and I are likely to watch fairly frequently. These DVDs are all ripped to our server so we can watch them without digging out the disc. It also means we can watch them in the bedroom on our small Media Centre that doesn't have a DVD drive.

We've recently upgraded out living room Media Centre to Vista Ultimate which works differently with ripped DVDs. The upshot of this was that I had to move all my discs from /DVDs/Title/Season/Disc to /DVDs/Title/Season Disc so /DVDs/Friends/Season 1/Disc 1A became /DVDs/Friends/Friends Season 1 Disc 1A (we need Friends twice so we see it in the list that Media Centre shows you).

Rather than doing this by hand for the 150 odd discs we have ripped I wrote a little Air App that renames and moves files or folders based on a Regular Expression that you enter. I think it works really well. You can just rename the file / directory or use the full path mode which allows you to move the file / directory as well. The larger screen shot demonstrates how it works.

You can get the air installer here and download source code here.

There is scope for some refactoring to make the presentation model smaller and there are a couple of other features that I could add but this did the job that I wanted it to do and didn't take too long to write.

Let me know what you think.

Picasa Tool

I love picasa, especially the new facial recognition features. It was always a bit of a pain linking pictures in Picasa to forum posts though, you had to strip out the url, add it to the [square] brackets and so on.

I've created a little tool that takes the link that picasa gives you and turns it into a forum-friendly link. It also lets you select the size you want and if you want a link included or not.

Take a look and tell me what you think:


a sample link provided from picasa:


Flex Components

I've already created a few Flex components and put them on my site for people to use but I thought I'd link to them here seeing as I have this brand new blog and lots of space to fill.

Carousel

I'm especially pleased with this component. So far it has been used by 2 of the clients that I have worked for over the past year or so. Initially it only took me 1 evening to write it. Since then I've had to make a few tweaks but the way it works is basically the same.

Slide Out Menu

This component has a nice little transition as you open each item in a list.

Hello World

Well, if anyone is reading this I have a reader!! :)

I am not expecting to get a large following writing this blog and to be honest I don't expect to be writing stuff very often as I don't really seem to have time for very much these days!

I am a Flex Developer currently working for Adobe Consulting in the city of London. I really enjoy being a developer and the project that I am currently working on in particular really does throw up interesting challenges to be dealt with.

In my spare time I like playing with cars. I have been to the Nurburgring a few times and plan to go a lot more this year. I have a Fiancee who I love dearly and we're getting married in 26 days on the 6th of March. Luckily she likes cars too and comes with me to Germany and on the many car trips I like to attend through the year.

I'll be using this blog to post anything that I think people might find useful. Any Flex components or applications I create or any solutions to tricky problems that I come across.
Give me a shout in the comments if you find any of this useful.

Thanks, see you soon.