Sep 30, 2008

Why Cairngorm? Why Not PureMVC

Hello Friends,

Quite often people asked me why Cairngorm? Why not PureMVC? Which is best?

My answere is that both are having some pros and cons so that would be a trade off. The best way is to understand the requirement of your project and then choose a particular framework. If you feel, both of them are not a best suit in your project then, you can just choose to extend one as per your requirement.

Here I compiled few points which I guess enough to justify why Cairngorm!! It also give you an idea of where you can use pure MVC

  • Cairngorm is a refined form of MVC pattern and is highly customized for medium to high complex flex projects. It takes advantages of native flex features such as binding. In comparison PureMVC is a more generic and isn't developed keeping in mind of any particular technologies so unable to leverage native flex features.

  • Cairngorm is a lot easier to learn than PureMVC and at least it delivers on the promise to let people quickly get up to the speed on large projects.

  • It is developed and used by Adobe Consulting, "The developer of Flex SDK". So while developing Cairngorm, they implemented the best practices to achieve maximum out of the flex SDK using a framework.

  • Cairngorm is Enterprise-Oriented and PureMVC is User Interface oriented. So, If an application that has a rich User Interface then the best choice is PureMVC, but if you rely a lot on a DB server and need to make many calls to get data from server, then Cairngorm is the best choice.

  • It is widely accepted in the flex developer community and probably most developers are familiar with it.

  • Cairngorm helps on large application breaking it in smaller pieces (classes), adding strength, reusability and flexibility. One wouldn't able to take much advantage of Cairngorm on small applications from the simple fact that the framework doesn't have room to express itself.

Sep 26, 2008

Warn on flex application exit

If you have been developing web based applications which require login, I am pretty sure you would have come across this question - How do you safe-logout the user if the user just closes the window/tab when there is unsaved information on the user’s screen?

My current Flex project requires the user to login and logout. And most of the time, the users never use the logout button. They just close the browser and walk away! :-x So, I needed a mechanism which will warn the user that there is unsaved information before closing the window. The way, I got this working was by using the FABridge.

In the application, I had an isAppDirty boolean.

public var isAppDirty:Boolean = false;

This variable is set to true whenever there is unsaved information in the application from any view. Now, add a few lines of javascript to your html wrapper. You can do this to the html file in the html-template folder.

————————————————————————————-

window.onbeforeunload = confirmExit;

function confirmExit(){
var flexApp = FABridge.flash.root();
var appDirty = flexApp.isAppDirty();

// note that the isAppDirty var is called like a function. This is done deliberately. Thats the way FABridge works :)

if(appDirty == true){
return “The configuration changes performed in this session have not been saved. If you wish to save the config, please click CANCEL.”;
}
}

————————————————————————————-

Do not forget to include the FABridge libraries in the html -


Thanks,

Shaleen Jain

Implementing the Flash Player Cache feature

In this article I will be telling you how to creating a dynamically linked application i.e how to implement Flash Player cache feature by using RSLs with Flex Builder

But let us first know what is a statically linked application and a dynamically linked application

Statically linked application - Flex framework code and the application code will make the SWF file increasing the size of the SWF file

Dynamically linked application - Flex framework code will be added dynamically to the SWF code thus reducing its size
If you want to check the result of the above mentioned feature live the follow the steps

1. Create any flex application with some code

2. Get the true size of the application - Follow the steps
1. By default, Flex Builder adds debugging information to SWF files, so in order to see the true size of the application,
turn off the debugging information
2. To do this, add -debug=false to the Additional Compiler Arguments section of the Flex Compiler Properties dialog box

3. Check the size of the application by viewing the properties of the application’s SWF file created in the bin directory
Note down the size

4. Now go to Project Properties (right click on Flex project and select properties), then choose the Flex Build Path properties
and click the Library Path tab

5. In the Framework Linkage pop-up menu, change the link type from “Merged into code” to “Runtime shared library (RSL).”
Click OK to save the changes.

6. Build the project

7. Now check the file size of the SWF file. You will definitely be surprised!!!!

266268 bytes - BEFORE
- 125020 bytes - AFTER
——
141248 bytes - DIFFERENCE IN SIZE

Important things

When you choose the option to use RSLs, all of the debug information is removed.
So you can easily switch between a statically linked application and a dynamically linked application just by toggling the option in the Framework Linkage pop-up menu from “Merged into code” to “Runtime shared library (RSL).”

The framework RSL is the only RSL that is configured by default in the flex-config.xml file because every Flex application uses over 100K of framework classes. If you do add RSLs, the compiler will always load any RSLs you specify whether or not they are used by your application.

For more information on this check the following link
http://www.adobe.com/devnet/flex/articles/flash_player_cache_print.html