Friday 18 December 2009

Updating Flex 4 SDK GeneratedResourceModule Error

I was updating to the latest Flex 4 SDK today which was a bit involved. For ages we’ve been using 10708 and have been unable to upgrade to a later version as Parsley didn’t work with it. There were some changes to the ModuleManager interface or something like that and Parsley’s Module management code needed to be updated.

Anyway, the parsley bug had been fixed and I was having problems with an SDK bug that I had reported a while ago and which has now been fixed. It seemed like a good time to update to the SDK but it did take a while:

  1. Download and set up new SDK version 13099
  2. Spend a while fixing all the compiler errors and adjusting code to work with new framework
  3. Run App
  4. Got Module errors due to Parsley (as in this thread)
  5. Check out latest parsley code from SVN
  6. build parsley swcs
  7. Run App
  8. Get module errors again
  9. build parsley swcs properly
  10. Run App
  11. Get a different error:

param 2 incompatible
  virt Object mx.core::FlexModuleFactory/callInContext()
  over *
GeneratedResourceModule7445881329779043571_mx_core_FlexModuleFactory/callInContext
()
VerifyError: Error #1053: Illegal override of
GeneratedResourceModule7445881329779043571_mx_core_FlexModuleFactory in
GeneratedResourceModule7445881329779043571_mx_core_FlexModuleFactory.

     at global$init()

Initially I incorrectly blamed this on Parsley again. I did some googling and couldn’t find much about GeneratedResourceModule apart from this. That got me thinking about resource bundles. It turns out that all I needed to do was to re-build my resource bundles with the new SDK so they were compiled with the new Module interface. It was a simple step that I should have done straight away but I had forgotten.

Hopefully this post will save someone else a bit of time if they have the problem as well.

Monday 23 November 2009

XML Namespaces

Recently I have been lucky enough to be working on a project that uses LCDS so I don’t have to write XML translators – all the objects arrive from server ready typed – it is soooo much easier and saves an awful lot of time.

At home though I have started working with the Picasa data API which means I am back to writing translators.
This is a job I really don’t like – it never works the first time and takes a lot of trial and error to get it write. I am actually going to write a base translator class to make it a bit easier the next time I have to do it.

Getting to grips with xml can be tricky but when namespaces are involved it gets exponentially more difficult and annoying!

I’ll make a note of the syntax of how to deal with namespaces here so that next time I’ve forgotten how to do it I can look it up.

I am trying to retrieve the href of the link node below with the relevance of self:

<feed
    xmlns='http://www.w3.org/2005/Atom'
    xmlns:gphoto='http://schemas.google.com/photos/2007'
    >
    <link
        rel='alternate'
        type='text/html'
        href='http://picasaweb.google.com/Giles.Roadnight'
        />
    <link
        rel='self'
        type='application/atom+xml'
       href='http://picasaweb.google.com/data/feed/api/user/Giles.Roadnight'
        />
</feed>

My first attempt was as follows:

var href : String = xml.link(@rel=’self’)[ 0 ]@href;

but that didn’t work. The give away is this line:

xmlns='http://www.w3.org/2005/Atom'

declaring the default namespace for the xml. What worked in the end was this:

var atom : Namespace = new Namespace( "http://www.w3.org/2005/Atom" );
var href : String = xml.atom::link.( @rel == 'self' )[ 0 ]@href;

Hopefully that’ll save me (and maybe you) a few hours in the future.

Sunday 15 November 2009

Picasa Web Albums Data API

I have previously tried to get Flex to play nicely with the Picasa API. I use Picasa a lot and host all my pictures there so to be able to do things with them with Flex would be very useful.

Before I have had issues as there was no crossdomain.xml but having had a look at the docs today this seems to now be fixed (or I missed it last time) as detailed here.

There are a couple of small projects I want to build on this API so it’s great that I won’t have to proxy these calls through the server.

Saturday 10 October 2009

More Waving

I’m excited to learn that there is already an Actionscript client library that enables you to write a flex application as a Google wave extension!

Not sure what I would develop yet but there is a lot of scope for some cool apps I think.

http://code.google.com/p/wave-as-client/

http://wave-samples-gallery.appspot.com/results?q=flex

Google Wave – first impressions

I got my invite to Google Wave today and have had a bit of a play about. If you don’t know what it’s all about then here is a 10 minute video explaining the basics:

So far it’s a bit frustrating as I don’t know many other people who have Google Wave. I can see the potential and would love to be able to use all the features. I am actually organising a trip to Scotland for May next year with Linzi and 4 friends and Google Wave would be great to help organise that but only Linzi and I have access so we can’t use it.

So far I have installed Tweety which is pretty cool – you can get all your twits directly in Google Wave. I’ve also had a play with the map extension and the Sudoku extension.

So, if anyone from Google Wave is listening please give me 4 invites so I can use wave to organise our trip next year!

Monday 31 August 2009

Flex, Blaze DS and GAE

I’ve spent a fair bit of the long bank holiday weekend trying to get Blaze DS installed on Google App Engine but frustratingly I’ve not managed it so far.

I was working off this blog post but when I tried to create a flex project it would not validate the Blaze DS server. I think it is something to do with the flex context root that  he is using in the example. When the validator tries to do a test on that context it doesn’t work.

I’ll have another go next time I have some time. It’s annoying when you can’t get these things to work.

Other than that I am very impressed with GAE – the eclipse plug-in is really easy to set up and use. It builds a sample site with web kit and a server call for you which works as soon as launch it.

I really hope I can get it playing nicely with Flex.

FlexUnit 4 Beta 2

A new version of FLexUnit has been released as blogged about here.

The biggest improvements on the old version is a really easy to use FlexUnit ant task to run your tests as part of your CI build.

There were a couple of teething problems with the first version that they released.
The first issue was resolved very quickly with a new release within 24 hours or so of the first release.
I managed to get round the second issue by tweaking and re-building the ant task so that it would work on 2003 server. This fix may now be in the trunk build but I haven’t checked.

There is still a bit of an issue with setting up a trusted swf so that the tests can run but I understand there is a fix for this on the way.

Windows Live Writer Re-Install (again)

I’ve just had to go through another round of re-installing Live Writer and deleting any settings files that I can find.

The fix that worked last time for Live Writer not starting didn’t work this time but a re-install did.

I’ve looked for alternatives but have not been able to find anything that looks as good.

Any suggestions?

Sunday 23 August 2009

FlexBudget 0.1

I had a free weekend this weekend and actually stayed at home for the first time in ages. In between reminiscing about last weekend in Germany by racing the Nurburgring on my xBox 360 I spent quite a bit of time working on FlexBudget.

I have now basically got all the domain classes finished and all the tests written. This was true TDD – I didn’t even create any view components until 99% of the domain and tests had been written. I also wrote the tests first, checked that they failed then implemented the functionality. I did come across a bug with FlexUnit 4 doing this – sometimes if a test fails FlexUnit seems to not fail it and just say that 44/45 tests completed which was a bit weird.

You can see how far I have got here:

http://giles.roadnight.name/flex/FlexBudget/FlexBudget.html

90% of the work so far has been on the domain classes and not very much on presentation logic or views. The next step will be improve the user experience a lot – I’ll move all the new Account / Deposit etc windows into popups. There is no form validation at the moment either, just catching of events so I need to work on that.

The selected transaction panel was thrown together in about 30 mins after I had completed the rest as I wanted to play with it. This is what the app is about really – being able to tweak spending to see how it affects your overall budget. This component is pretty buggy and will throw RTEs if you click in the wrong place in the grid.

The view is not pretty, not well laid out and probably has some bugs in but I am pretty pleased with progress so far. Obviously the app is useless without what you enter being persisted in a database somewhere but that will come next after I have tidied the view up.

Try the following for an example of the functionality.

  • Create a new account called House with a balance of £500 and a date of the 1st (make up an account number)
  • Add the following withdrawals (amount, date, description, code):
    100, 10th, Gas Bill, DD
    75, 15th, Electric Bill, DD
    1000, 15th, Rent, SO
    200, 20th, Council Tax, DD
  • Add another account called personal with a balance of £100 and a date of the 1st (make up a number)
  • add a deposit of £2000 to personal on the 10th – Wages / CHAPS
  • Add a Transfer from personal to home on the 14th of £1000
  • Add a withdrawal to personal on the 2nd for £200 called Night Out with code ATM
  • Click on the night out transaction in the grid and change the date to the 11th (in the Selected Transaction Panel )
  • Click on Gas Bill and change the amount to –50

Eventually you’ll be able to drag transactions around to a new date and amounts etc will be editable in the grid.

I’m looking forward to getting this into a useable state so I can stop using a spreadsheet!

Any comments or ideas for features please let me know.

Saturday 22 August 2009

Windows Live Writer working again

For the last few weeks whenever I have tried to start Windows Live Writer on my desktop it just crashes straight away. I tried repairing it, uninstalling it, re-installing it, looking at log files and so on and so on and nothing worked.

Today however I found this blog post:

http://jcheng.wordpress.com/2009/02/08/windows-live-writer-2009-wont-start/

and deleting the files in the mentioned directory worked.

That’ll save me a bit of time as I was considering writing my own blog client in Air!

Sunday 9 August 2009

FlexBudget

I’ve spent quite a bit of time this weekend working on FlexBudget. I am pretty pleased with my progress.

I haven’t created a single view component yet b8t have just been working on the domain classes and tests.

For this sort of project TDD really comes into it’s own. As I say, I haven’t created a single view component yet but when I get to that stage I can be fairly sure that all of the domain classes will work fine – including all binding.

So far I have created the following domain Classes:

  • Account
  • AccountAdjustment
  • Transaction
  • Balance
  • Withdrawal
  • Deposit
  • Transfer

Balance, Withdrawal, Deposit and Transfer are all Transactions. Each Transaction has at least one AccountAdjustment which is associated with one account. A withdrawal has one AccountAdjustment – a withdrawal with a negative amount. A Transfer has 2 account adjustments, a withdrawal from one account and a deposit in another account.

Each account has a collection of account adjustments that are sorted by date. The balance of the account is calculated by each adjustment being passed the balance of the previous adjustment and then working out the new value.

There is quite a lot of testing to make sure that if you update the amount or date of an account adjustment the amount property on the associated transaction updates (and the binding fires) and if there are any other adjustments for that transaction that the amount updates there as well.

The next step is to create a Budget class that will hold a collection of Transactions and a Collection of Accounts. The accounts will be used to generate an array of DataGridColumns and the transactions will be used as a dataprovider.

Observe / ObserveValue

I don’t know what is happening with blogs.adobe.com but a lot of pages seem to be down or missing. I can’t find anywhere to download Paul Williams’s Observe tag and Alex Uhlmann’s blog about it seems to be down as well.

I’ve uploaded them here so if you’re wanting them grab ‘em quick.

I worked with Paul and Alex on my last project at Morgan Stanley. Both are very talented developers and good fun to work with.

Saturday 8 August 2009

EventListener

This is a little class I wrote that make it a bit easier creating and removing event listeners.

If you have ever written code like this:

public function set model( value : myPM ) : void
{
if( _model )
{
_model.removeEventListener(
"someEventType",
myFunction );
}

_model = value;

if( _model )
{
_model.addEventListener(
"someEventType",
myFunction );
}
}

Then EventListener should make your life a bit easier. The above code in MXML would become:

[Bindable]
public var model : MyPM;

]]>

target="{ model }"
type="someEventType"
handler="{ myFunction }"
/>

And in an as file:

private var domainListener : EventListener = new EventListener(
null,
DemoDomain.SAMPLE_DOMAIN_EVENT,
domainHasDoneSomething );

public function set demoDomain( value : DemoDomain ) : void
{
domainListener.target = value;

_demoDomain = value;
}

I think it makes your code look a bit nicer – especially in mxml files where you can just declare the event listener and use bindings.

There is also a passEvent property that determines if the event is passed to the handler function.

I’ve put a demo of it in use here with view source enabled and a download of the source code. This demonstrates an event listener with a target of a domain model. You can then inject the domain model into the PM, the PM then dispatches an event when it receives an event form the domain. IF you remove the domain from the PM the event listener is the cleaned up and the PM no longer dispatches events.

Let me know if you find it useful.

Flex Formatter Eclipse Plug In

At work recently I’ve been using a Flex Formatter eclipse plug in. It’s REALLY useful and saves so much time.

Take a look here.

Saturday 1 August 2009

Parsley 2.0

On my last 2 projects I have been using Parsley 2.0. An IOC framework for Flex.

It is an alternative to Cairngorm and does a lot more on top. I have used Cairngorm for a long time and did like it but when you get used to Parsley you really start to appreciate the benefits.

Tom Sugden who I worked with on my last project has written a good blog post about IOC in general here and has some specifics about parsley.

I’ve implemented a sample project that demonstrates dependency injection, managed events and modules. The sample is here and a zip of the project is here. This is a Flex 4 project so you’ll need to download Parsley from SVN and patch it.

The sample project has 2 views in the root with a different instance of the same PM injected into them. The PMs both have the same global domain object injected into them that has a string in. This string is displayed in the text area and you can see that any changes are reflected in both views.

You can also load Module 1 and then load Module 2 inside Module 1. Parsley creates a child context for each of these modules but messages still flow to and from the modules as does the injecting of the global domain object.

The area at the bottom of the screen is a custom log target that displays logs from parsley so we can see what’s going on.

If you want to find out more about parsley the spice factory home page is here. There is some great documentation and a really good forum with excellent support from the creator Jans Halm.

Sunday 5 July 2009

End of an Era – leaving MS

Friday was my last day at Morgan Stanley. I had a great time working there, made some good friends and met some very talented developers.

I was there for just over a year and learnt so much in that year.

It was quite sad leaving on Friday and I nearly had a tear in my eye at one point (but don't tell anyone ;) ). I'll only be across the road at my new job with HSBC though so I'll still be able to meet up with the guys.

Here is a picture from the last pink shirt Friday. It was the first time I participated as the pink shirt was a leaving present.

A special mention to Alex, Ged, Johnny, Ben, Sam, Leon, Tom, Dianne, James, Christie, Nick and Claire. I hope we’ll stay in touch and stay friends.

Sunday 21 June 2009

Picasa Tool Update

I’ve updated my picasa tool slightly. Firstly I have corrected the spelling from picassa to picasa and I have added some more text fields. This is mostly to make it easier for me to include pictures on my car blog.

Updated version is here:

http://giles.roadnight.name/picasaTool/

There is still more that I would like to do with this tool. Ideally you’d be able to log directly into your picasa account and browse the albums and images directly and pick your image in that way.

Previous attempts to do something similar got tricky as picasa does not have a crossdomain.xml file.

Maybe I’ll do it in an air app one day.

Skinning Panel with borderSkin

I spent far longer than I should have about a week ago trying to skin Panel. This should have been a simple task but it took me about 2 days.

What I was trying to achieve was to skin a Panel with an asset from Flash as a border skin. To begin with we have an un-styled Panel (all the below versions have view source enabled):

If we then add a borderSkin style we can see that the content of the Panel overlaps the titleBar and controlBar:

As we are using our own skin class in this example one possible fix is to make our skin class extend IRectangularBorder:

The problem is though that if we are using an asset to skin our panel we can’t make the asset implement IRectangularBorder. Looking at the code for Panel there is a get viewMetrics function that is supposed to calculate the border around the content area. In our case this is not working so it seems logical that we can override it as follows:

override public function get viewMetrics() : EdgeMetrics
{
    var metrics : EdgeMetrics = super.viewMetrics;
    if( titleBar )
    {
        metrics.top = titleBar.height;
    }
    if( controlBar )
    {
        metrics.bottom = controlBar.height
    }
    return metrics;
}

However if we do this we get this result:

We get extremely odd behaviour in all sorts of other view components even outside our panel. The extra top and bottom that we add to the view metrics seems to get progressively applied to buttons, other non styled Panels and all sorts of other view components.

The solution to this is to change the above code very slightly:

override public function get viewMetrics() : EdgeMetrics
{
    var metrics : EdgeMetrics = super.viewMetrics.clone();
    if( titleBar )
    {
        metrics.top = titleBar.height;
    }
    if( controlBar )
    {
        metrics.bottom = controlBar.height
    }
    return metrics;
}

And we get the following:

I can only guess that the layout class used by Panel retains references to the EdgeMetrics objects returned from super.viewMetrics and this somehow messes up the layout of other components.

I have submitted a bug here that you can vote on if you like.

I hope this blog post helps someone else out who comes across the same problem.

Tuesday 9 June 2009

Read Write Web article on the Matrix

Read Write Web have an article on the Matrix. They are pretty enthusiastic. Have a look here.

I think that this is all based on the microsite and don't think that they have looked at the actual app.

Shared via AddThis

Tuesday 2 June 2009

Morgan Stanley Matrix

I’m finally allowed to talk about the project that I have been working on for pretty much the last year. I have been working for Morgan Stanley on a sales and trading platform.

This is by far the biggest project I have ever worked on and there are some really talented people on the team. I have really enjoyed working on this project. I have learnt so much in the last year. Despite the product launching soon there is still a lot of work to keep us all busy for the next few months.

Obviously I can’t link to the actual app as you need a login but there is a microsite that you can take a look at. I didn’t actually work on the microsite but it gives you some idea of what the actual application is like.

http://www.morganstanley.com/matrixinfo/

Google Wave

I'm really excited about Google Wave. It it becomes widely accepted I think it could be really useful. Check out the video:

http://www.youtube.com/watch?v=v_UyVmITiYQ

Saturday 30 May 2009

Tweens in Flex

I came across a problem I've had before with Flex yesterday. Sometimes Tweens (and anything that relies on a Tween such as a Move or a Resize) just doesn't work. You call play() but you don't get any events from the Tween, not even a tweenStart event.

On another project I had this problem and had to write my own Tween which I called WorkingTween. I had to re-implement it yesterday.

I think it is a better implementation anyway as it just uses event listeners, you don't have to supply a listener object and you don't have to implement tweenUpdate and tweenEnd method (which you have to make public when using Tween).

My Tween you supply a startValue, endValue, duration and optionally interval and easingFunction. You then add listeners to the standard TweenEvent - tweenStart, tweenUpdate and tweenEnd.

Has anyone else had trouble with the standard Tween?

AlternativaPlatform

I jsut came across these people:

http://alternativaplatform.com/en/

and they've done some very cool stuff with 3d in Flash. Go and take a look.

Sunday 24 May 2009

FlexBudget

I’ve not posted in a while as I’ve had very little time to work on any projects outside of work.

I’m currently working on a project I am calling FlexBudget whenever I can squeeze a few hours coding in at home.

I hope to run this off a Google App Engine Backend which will be interesting to play with.

The app will enable you to set up a number of accounts, tell it about you Direct Debits and other outgoings and about any incoming funds. It will allow you to see when your account is going to go overdrawn and let you plan when and what to spend. You’ll be able to enter recurring transactions and one offs.

Eventually I want to be able to upload a CSV file taken directly from your online banking to it and let the app find your direct debits and work out how much you spend in a normal month.

So far I have defined the main domain models – Account, Transaction and AccountAdjustment and have written the unit tests and functionality for Account. This project is well suited to TDD so that is the approach I am using.

The app will basically be one big data grid. The dataProvider will be a collection of Transactions. Each transaction will contain at least 1 account adjustment (2 for a transfer for example as it involves 2 accounts). Each account will have a collection of AccountAdjustments passed into it and will calculate the balance of each. The Transactions will then use this calculated balance to render the data grid.

I’ll find this app useful in planning weekends away to track days and other car – related holidays. They’re not cheap so being able to see how much money you’ll have left at the end of the month after 4 weekends away is useful!

I’ll keep you updated as I go along.

Thursday 16 April 2009

Java support on Google App Engine

Java is now supported by Google App Engine. I've been waiting for this as I didn't want to learn Python. I do want to learn Java though and want to play with app engine so now I've got no excuse. Just need to find the time now!

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.