« December 2007 | Main | February 2008 »

January 21, 2008

InsideRIA launched today

Check out InsideRIA.com which was launched today. It's an online community developed by O'Reilly and sponsored by Adobe, which will provide a number of resources for information about RIA's, RIA development, and that which is related, with lots of attention on Flex, AIR, Actionscript and Flash.

January 16, 2008

'Designing For Flex' series on devnet

If you haven't seen it yet I highly recommend taking the time to read through Rob Adams's 8 part series of articles about designing Flex applications. The last article in the series, Making your Applications Safe, just went live a couple of days ago. It's an excellent guide to creating good experiences for your users.


The Designing for Flex series includes the following articles:

January 14, 2008

Deferred instantiation of mediators in a PureMVC Flex application

I'm creating my first project using PureMVC after using Cairngorm for a few projects. Once I started understanding the concepts and intent behind each of the architecture components (Proxies and Models, Views and Mediators, Controllers and Commands), it's been great in it's relative simplicity. I did printed out the docs and read over them everyday at lunch for a few days in a row just make it all really sink it, but it didn't take too long to click.
The best part is that I've had a few questions so I decided to check out the PureMVC forums on the PureMVC site. So far everything I've searched has returned a thread with a very detailed, extensive answer from Cliff! The days go so much easier when there's easy to find and good information about whatever your working with.

One of the problems I ran into pretty quickly was that I had a TabNavigator with 3 tabs where the contents aren't to be drawn or loaded until they are clicked on.
I initially tried to register the mediators for those 3 view components at startup, which to no surprise threw runtime errors because the views didn't yet exist. Not being sure what the best solution was here, I searched the forums and found this thread.

I went with Cliff's recommendation (deferred instantiation) and here's what I have now:

My TabNavigator has 3 tabs each containing one custom component named "tags", "groups", "info".
In each of these components I have a creationComplete event which calls an onCreationComplete function, which in turn dispatches a custom Event:

dispatchEvent( new ComponentLoadedEvent( ComponentLoadedEvent.COMPONENT_LOADED, true, false, this ) );

The mediator of the TabNavigator itself listens for this event and calls handleLoad when it hears it:

mainComponent.addEventListener( ComponentLoadedEvent.COMPONENT_LOADED, handleLoad );

The handleLoad() registers the appropriate mediator for the loaded component:

public function handleLoad( e : Event ):void
{
    var component :Object 	= e["component"].name;
			
    switch(component)
    { 
        case "tags":
            facade.registerMediator( new TagsMediator( mainComponent.tags )  );
            break;
        case "groups":
            facade.registerMediator( new GroupsMediator( mainComponent.groups )  );
            break;
        case "info":
            facade.registerMediator( new UploadStatusMediator( mainComponent.info )  );
            break;
    }
}


Creating authenticated/signed Flickr API calls in Flex/Actionscript

Since the individual doc pages for the Flickr API calls don't tell you how to create a signed API call, it took me a minute to figure it out. This info can be found in the Flickr User Authentication docs, but here's how to create a signed call.

Let's say you want to call flickr.people.getUploadStatus.
Well, the call requires authentication or else it won't do you any good. Once you are authenticated you create the call by performing the following steps:

1) Create a string using the required parameter names plus their values in alphabetical order (i.e. "api_key" + api_key_value .) Then preceed this string with the shared_secret, and append the string with the string "method" plus the method name. Note that every authenticated call requires both the auth_token and api_sig arguments.

So, in the case of flickr.people.getUploadStatus the string would look something like:

var api_sig : String = shared_secret + "api_key" + api_key_value+ "auth_token" + token_value + "method" + "flickr.people.getUploadStatus"

2) Then get the MD5() of this string. As I mention in another post, I use this class, and simply call MD5.encrypt( myString )

var api_sig_encrypted : String = MD5.encrypt( api_sig );

3) We can then make the call:

var params : Object = { "method": "flickr.people.getUploadStatus", "api_key": api_key, "api_sig" : api_sig_encrypted, "auth_token" : auth_token }; 
codeService.request = params;
codeService.url 	= "http://api.flickr.com/services/rest/";

codeService.addEventListener( ResultEvent.RESULT, getUploadStatusResult );
codeService.addEventListener( FaultEvent.FAULT, faultResult );

codeService.send();

MD5 for Actionscript

I'm working on a Flex/AIR application that requires Flickr authentication so I needed an MD5 class for Actionscript. Here's the one i've been using and it's been working great. It's simple and doesn't have a load of extra unnecessary baggage.