Tuesday, December 23, 2008

Determining Inactivity in Flex (FlexEvent.IDLE)

A FlexEvent.IDLE event is dispatched every 100 milliseconds when there is no keyboard or mouse activity for 1 second.

In order to use the following event we need to import the following classes.
1. import mx.managers.SystemManager;
2. import mx.events.FlexEvent;
3. import mx.core.mx_internal;

You’ll need to tell your program that you want to use mx_internal as a namespace to access those properties within the SystemManager class. SytemManager has an “idleCounter” property which is super useful to access- but it is scoped to mx_internal and is not normally accessible. Trying to access it without these steps will throw an error:

1. use namespace mx_internal;

SystemManager is automatically instantiated as a part of every Flex app, so we do not need to do this manually. We will, however, need to add an event listener for FlexEvent.IDLE:

1. this.systemManager.addEventListener(FlexEvent.IDLE, userIdle);

Construct the callback method. One minutes is equal to 60000 milliseconds… divided by 100 ticks and the number we need to check against is 600. Of course, you’ll probably want something a little shorter in duration for testing:

private function userIdle(e:FlexEvent):void {
if(e.currentTarget.mx_internal::idleCounter == 600){
//do something!

Note that we prefix the idle Counter property with the mx_internal namespace.

That’s it! Now we have a sweet little activity monitor in our app. When activity is detected, idle Counter will automatically reset as well.

Sunday, December 7, 2008

Ribbit - Integrate Voice and Rich Communication

Ribbit - An open platform for multi-protocol communication for creating cool voiceware applications.
The Ribbit API's are simple and gives the opportunity to create new communication solutions for all sort of demands.
It enables developer to bring richness of voice calling and Web 2 Experience. You can add voice and Messaging service to your application without any traditional mobile phone intervention.
One thing that i found really good in Ribbit API is that Voice and Message can be delivered and received on multiple devices in multiple location across any sort of network.

Sunday, August 10, 2008

Modern programming languages provide a mixture of primitives for composing programs. Most notably Scheme, Smaltalk, Ruby, and Scala have direct language support for parameterized delayed-execution blocks of code, variously called lambda, anonymous functions, or closures. These provide a natural way to express some kinds of abstractions that are currently quite awkward to express in Java. For programming in the small, anonymous functions allow one to abstract an algorithm over a piece of code; that is, they allow one to more easily extract the common parts of two almost-identical pieces of code.

Closure Literals

We introduce a syntactic form for constructing an anonymus function value:

{ FormalParametersopt => BlockStatementsopt Expressionopt }

Evaluating the closure literal expression results in a closure instance . A closure instance is converted to some object type by a closure conversion. In the nominal version of the specification, it is a compile-time error if a closure literal appears in a context where it is not subject to a closure conversion. In the functional version of the specification, if a closure literal is not subject to a closure conversion it is converted to the corresponding function type of the closure literal, which is the function type with: identical argument types; a return type that is the type of the final expression, if one exists, or java.lang.Unreachable if the closure literal's body cannot complete normally, or void otherwise; and a throws type list corresponding to the checked exception types that can be thrown from the body of the closure literal. The conversion, in either case, occurs entirely at compile-time.

A closure literal captures a block of code - the block statements and the expression - parameterized by the closure literal's formal parameters. All free lexical bindings - that is, lexical bindings not defined within the closure literal - are bound at the time of evaluation of the closure literal to their meaning in the lexical context in which the closure literal appears. Free lexical bindings include references to variables from enclosing scopes, and the meaning of this, break, continue, and return. Evaluating the closure literal does not cause the statements or expression to be evaluated, but packages them up at runtime with a representation of the lexical context to be invoked later.

At runtime, if a break statement is executed that would transfer control out of a statement that is no longer executing, or is executing in another thread, the VM throws a new unchecked exception, UnmatchedNonlocalTransfer. Similarly, an UnmatchedNonlocalTransfer is thrown when a continue statement attempts to complete a loop iteration that is not executing in the current thread. Finally, an UnmatchedNonlocalTransfer is thrown when a return statement is executed if the method invocation to which the return statement would transfer control is not on the stack of the current thread.


Varun Rathore

Saturday, August 9, 2008

Cairngorm Is Open Source Now

This week Adobe announced that Cairngorm has been moved to from Labs to opensource.adobe.com.

So what does this mean for you, as a developer, building RIAs targeting the Adobe Flex platform on top of Cairngorm?

It means a lot.

The most significant being that Cairngorm now has a formal community based initiative. This in itself facilitates positive growth as it encourages community feedback and collaboration. It allows the community to have an open pool for discussion, collaboration and most important, knowledge sharing.

R u willing to contribute?
To begin, start by signing up as a member and sharing your thoughts and experiences. Get involved; engage in conversations with the rest of the community. Take a look under the stage; get to know Cairngorm internals (if you don’t already).

Expect Good Things To Come Now..


Varun Rathore

Friday, August 8, 2008

dpHibernate - Hibernate lazy loading with Adobe BlazeDS

One of the biggest problems with working with data in a RIA/Flex application is that it's all or nothing. You either need to get all of the data or write a lot of code to return the data in multiple requests. The problem is that good design means that we want to design our data object to match the data, not the UI. For instance a User might have an array of Orders which each have an array of Items. Seems simple enough, right. The problem is that this is a large complex objects which could require a query that joins multiple tables when returning data to your application. No big deal if you want to display all of the data. But if you are just trying to output the users name and email in a search result screen then this is a huge performance hit.

Luckily there is a solution, It is called lazy loading. JSP developers, which use the java hibernate framework, have been able to use lazy loading for years. But until now this did not work with remote client applications like Flex. For those of you who have tried, I'm sure your familiar with the dreaded LazyLoadingException. Frustrating huh. Lazy loading let's your define a complete object model, such as a User with an array of Orders. But only return the data you are actually using in your presentation layer (Flex). Avoiding that all or nothing data problem that is so common.

I'm happy to announce a new Digital Primates open source project. dpHibernate, add support to BlazeDS for Hibernate lazy loading. You can find both the java and the ActionScript parts of the project here:
If you're not familiar with hibernate, check out http://www.hibernate.org. At a real high level, Hibernate is a java ORM tool, which lets you map java beans to a relation database. Hibernate does all of the sql work for you.

So how do dpHibernate work? dpHibernate is actually a combination of two code bases. First, there is a custom java adapter for the BlazeDS server. This HibernateAdapter understands the hibernate proxy objects and knows how to convert them into a special dpHibernate proxy which the AMF serializer will ignore and not try to initialize. This is how the proxy objects are able to go back to the client without getting the LazyLoadingException.

The second part of dpHibernate is an ActionScript library which gives your application the code it needs to understand these dpHibernate proxy objects. This AS library has the code to manage your ActionScript beans and knows how to call back to the server to load a proxy once that object has been touched, usually with a binding expression.

In case your wondering, how does dpHibernate differ from the hibernate support in LiveCycle Data Services ES? For one dpHibernate doesn't require LCDS it works with the open source BlazeDS server. The other big difference is that hibernate support in LCDS requires you to duplicate the lazy associations in the services-config.xml and you need to use an Assembler class to get the hibernate objects. dpHibernate let's you call any java method and return any hibernate object.

So check it out, if you can use it I'd love to hear about it. If it doesn't work for you I want to know about that too. And as with all open source projects this one can use as many eyes as possible on it too. If you find any hibernate configurations that don't work let me know. Or better yet, send me a test case with the right hibernate mapping files to recreate the issue.

Thursday, August 7, 2008

Cool Flex Refresh Component

The HttpRefresher component can refresh data from server-side at specified intervals.

FleXtense - Open Source

FleXtense is an application for Flex Users which composes the automatic ActionScript proxy classes for accessing the web services. It provides to compose rapid and safe codes with its supporting data types and easy to use interface. FleXtense is a platform independent application because it has taken wsdl schema standart which are based from World Wide Web Consortium (w3c.org). You can use FleXtense with Java, .net, pHp, Ruby etc.

Complete Uninstalling -- AIR Application

Uninstalling and reinstalling the application dont delete the retained my user data. You’ve probably seen similar behavior in some of your AIR applications. The problem is that when you uninstall an AIR application it doesn’t get rid of the encrypted local store data. Here’s the solution.

Basically if you want to completely blow away an AIR app you need to go into the “/Users//Library/Application Support/Adobe/AIR/ELS”, find your application based on the id and then delete the application data.

On Windows it’s “C:\Documents and Settings\\Application Data\Adobe\AIR\ELS” (ELS stands for Encrypted Local Store).


Varun Rathore

Friday, July 18, 2008

Saving Encrypted Data in AIR

Have you ever wanted to store a users password, you know, that little checkbox that says 'Save Password' on any login form. Or maybe you just want to persist a session token or other information. You could use the Local Shared Objects or even the File API, but that isn't very secure. How do you store sensitive information that your AIR application needs to persist?

Luckily, there is an often overlooked API for just this use case. It is called the EncryptedLocalStore and is actually quite simple to use. The EncryptedLocalStore API persists data to the local system using a name-value pair scheme that is specific to each application. The name is a simple string, and the data is a ByteArray. The data is stored using both the application ID and the user information from the local system, so other AIR applications and other users cannot access the data. This API is actually hooking into the Keychain functionality on Mac and DPAPI on Windows. The data is encrypted using AES-CBC 128-bit encryption. So the main point to take away is that the data is very secure and other AIR apps or users will not be able to easily access it.

So, how do you actually use the API? Well, lets assume that we have a session ID that is a string and we want to persist in the EncryptedLocalStore. Lets also assume that the session ID is stored in a variable called 'sessionId'. One thing to keep note of is that the data must be stored as a ByteArray, so we first need to create a ByteArray instance and add the string value to it. The code might look something like this:

var bytes:ByteArray = new ByteArray();
bytes.writeUTFBytes( sessionId );
EncryptedLocalStore.setItem( "sessionId", bytes );

To retrieve the data, you simple retrieve the ByteArray using the getItem API, and then read your UTF string value out of that ByteArray:

var sessionIdBytes:ByteArray = EncryptedLocalStore.getItem("sessionId");
var sessionId:String = sessionIdBytes.readUTFBytes( sessionIdBytes.length);

To remove an item from the store, you simply call the removeItem API:


There are a few things to note when using the EncryptedLocalStore API. First, the API is syncronous and is geared towards small amounts of data. While there is no practical limit, any ByteArrays larger than 10MB might cause performance issues. Second, when debugging your application using ADL, we are actually using a different store than what is being used for installed applications. And last, when uninstalling an AIR application, the data in the EncryptedLocalStore is NOT deleted.

One last note as well, this API is available to both Ajax and Flash based AIR applications, like all ActionScript APIs.

Free Flex Builder 3

As announced recently, Adobe is offering Flex Builder 3 with Charting free of charge to educational establishments and students. The link to register for your free download is now on the Adobe developer connection site, or you can access the registration site directly at Register Link

When registering you will need to provide proof of eligibility - so that means you’ll need to scan in a copy of your student ID or a letter on an educational institution letterhead stating that you are a current student. Once you’ve got that you’re good to go and get your free copy of Flex Builder.


Varun Rathore

Thursday, July 17, 2008

List of JVM options

I just want to share what I believe is the most extensive list of JVM options - most of them cannot be found in the original documentation. Also you can find a lot of useful resources related to garbage collection and performance.


Varun Rathore

Flex and Java application with LCDS (LiveCycle Data Services) without server side code

LCDS 2.5 brought a new assembler, SQLAssembler. SQLAssembler lets you connect your Flex client to your database. Usually, when you read/write data with LCDS, you create your own Java adapter to handle these operations. With SQLAssembler, instead of writing the Java code for accessing the database, you configure access to the database and write the SQL for read/write/delete directly into the data-management-config.xml file (this is a configuration file used by Flex data services). Basically, you write some simple XML with some SQL for each operation, and you don’t need to write a single line of Java. But, you get a full CRUD application, with all the benefits of Flex Data Services: collaboration, conflict resolution, paging. If you need for some operations to use stored procedure instead of SQL statements, there is no problem as SQLAssemberl has support for them.

Why should you use SQLAssembler?

I will not try to fool you. Probably it isn’t good for complex applications, where you have a lot of business logic on your server. But, it could come in very handy when you need to create a simple application, maybe a quick prototype for example. And the best thing is that if, for some reason, you decide that you need a custom assembler or HibernateAssembler instead of SQLAssembler, there should be little to change in the Flex client code, if anything at all. And, as you will see in this article, I can use this assembler to create a full CRUD application for one-to-many relationship database setup.

Merapi - A Bridge Between AIR and Java

Merapi is a bridge between applications written in Java and those running in and created for Adobe AIR™ (Adobe Integrated Runtime™).

Merapi has been designed to run on a user's machine, along with an Adobe AIR™application and providea direct bridge between the Adobe AIR™ framework and Java, exposing the power and overall calabilities of the user's operating system, including 3rd party hardware devices.

With a light weight and straightforward API, developers can leverage the OS by writing Java companion applications for their AIR™ applications. Java programs treat Mirapi as a bridge to the running Adobe AIR™ application and vice-versa.

Developers can build their Flex, Flash and AJAX applications for Adobe AIR™, and use Mirapi to make them do things that AIR just can't do by itself.

The Merapi project team, is proud to announce that the private alpha release has been completed and is available to select members of the Flex/AIR/Java community. We've had a lot of interest and have been contacted by a variety of individuals who have expressed interest in joining our efforts.

Adobe New Magical Tool For RIA - THERMO

"Thermo" is an upcoming Adobe product that makes it easy for designers to create rich Internet application UIs. Thermo allows designers to build on familiar workflows to visually create working applications that easily flow into production and development.

Features :-

* Use drawing tools to create original graphics, wireframe an application design, or manipulate artwork imported from Adobe Creative Suite tools.
* Turn artwork from Adobe Photoshop, Illustrator, or Fireworks directly into functional components that use the original artwork as a “skin”.
* Define and wire up interactive behavior, such as what to do when a user clicks on something, without having to write code.
* Easily design UIs that work with dynamic data, such as a list of contacts or product information, without having access to the actual data source. Design-time sample data can be used as a realistic placeholder when laying out an application, testing interactivity, and choreographing motion.

Applications created in Thermo are Flex applications that can be loaded directly into Flex Builder, providing a great roundtrip workflow for designers collaborating with developers. The designer's work can be incorporated directly into the production application with no loss of fidelity, and designers can continue to refine the design throughout the iterative development process.

Friday, June 6, 2008

Changing Mysql Password

Last day i lost my mysql password , so i had to uninstall the whole database server and reinstall, then going mysql site i found a way to change my pass word , hope this may help u

Let’s look at all the ways to change MySQL password, for root and other users:

In MySQL the default password is empty. This is inherently unsafe and should be immediately changed. Here is how you can change MySQL default root password:

mysqladmin -u root password NEWPASSWORD

Here is how you can change OLDPASSWORD to NEWPASSWORD


Replace LOGIN with your login name, OLDPASSWORD with your current password and NEWPASSWORD with the new password.


Varun Rathore

Object Comparison In Flex / AIR

Object Comparison In Flex/AIR

To compare the objects whether they are same or not we can use following method of SerializeUtil Class

public class SerializeUtil
public static function ObjectToString(object: *): String
var ba: ByteArray = new ByteArray();
return ba.toString();
public static function ObjectToByteArray(object: *): ByteArray
var ba: ByteArray = new ByteArray();
ba.position = 0;
return ba;

To do the actual comparison just use these lines of code to compare the two objects.

if (SerializeUtil.ObjectToString(object1)==SerializeUtil.ObjectToString(object2))
// Objects are 'equal'
// Objects are not 'equal'

Thanks and Regards

Varun Rathore

Friday, May 16, 2008

Custom Event Creation and Data Passing

Passing Data With Custom Event

As being an event driven language Action Script provides the mechanism of sending any kind of object with
the event.The concept is more important when we are supposing to get value of any varialbe of mxml into
any another mxml which is far enough in the structure(Folder Structure)of our Application. It is very simple
to create any custom event for the occurence of any particular event.Within the same parent folder in which
your mxml containing the variable create a folder (let suppose with name ‘event’).In mxml let's suppose
variable of arrayCollecton ‘myCollection’ is defined and it is already assigned some data.
Now we will create a custom event ‘CustomEvent’ in the folder where your mxml(which is having that arrayCollection)is present.

Just create one action Script class file Copy and Paste the code below.
package myPro.events
import flash.events.Event;

public class CustomEvent extends Event

public var mybool:Boolean=true;
public var myCollection:ArrayCollection;

public function PropertyThumbEvent (type:String,myCollection,mybool:Boolean=true):void
this.myArrayCollection = myArrayCollection;
this.b=b ;

override public function clone():Event
return new CustomEvent(type,myCollection,mybool);


Now at this mxml where ‘myCollection’ is present First add Metadata as below :-



Again from the same mxml just dispatch one event i.e. as:-

dispatchEvent(new CustomEvent(”myCustomEvent”,myCollection,true));

we can use it as follows:-


Creating FullScreen Flex/AIR/Flash Applications

Going Fullscreen in Actionscript

The main stage for the AIR application has a displayState property. The framework also contains a class, StageDisplayState, that defines three constants for the three different display states. By using these classes you can put your AIR application into any of the three display states .

PLAIN TEXTActionscript:
// Enter Fullscreen Interactive State
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
// Enter Standard Fullscreen State
stage.displayState = StageDisplayState.FULL_SCREEN;
// Enter Normal State
stage.displayState = StageDisplayState.NORMAL;

we can use these as follows :-

Going Fullscreen through JavaScript

The logic works exactly the same in JavaScript as it does in Actionscript, but the classpaths are different. You can see the examples below in Code Example 2.

// Enter Fullscreen Interactive State
window.nativeWindow.stage.displayState = runtime.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE;
// Enter Standard Fullscreen State
window.nativeWindow.stage.displayState = runtime.flash.display.StageDisplayState.FULL_SCREEN;
// Enter Normal State
window.nativeWindow.stage.displayState = runtime.flash.display.StageDisplayState.NORMAL;


Varun Rathore

Thursday, May 15, 2008

Flex 4 (Gumbo)

Flex 4, codenamed Gumbo, is now beginning active development. The product plan is not yet complete, but a few themes are under consideration:

Design in Mind: provide a framework meant for continuous collaboration between designer and developer. Probably involves an additional component model that integrates with the existing Halo components.
Accelerated Development: take application development from concept to reality quickly. Features could include application templates, architectural framework integration, binding improvements.
Horizontal Platform Improvements: features that benefit all application and user types. Features could include compiler performance, language enhancements, BiDi components, enhanced text.
Broadening Horizons: expand the range of applications and use-cases that can leverage Flex. Features could include finding a way to make the framework lighter, supporting more deployment runtimes, runtime MXML.

Download Flex 4 build


Varun Rathore

Flex Development Frameworks

1. Puremvc Framework

PureMVC is a lightweight framework for creating applications based upon the classic Model-View-Controller design meta-pattern.

2. Cairngorm Framework
Cairngorm Framework is the most widely accepeted framework with Flex development.

3. Prana Framework
Prana Framework is runtime control framework and made on the basis of spring framework.

4. Foundry
Foundry ( sbasfoundry ) is an ActionScript 3 / Java framework designed for Flex 2 applications development.

5. Guasax Flex Framework
Guasax is an ease of use programming framework to provide ordered and scalable Flex applications.
Life cycle of guasax framework is based in the MVC pattern to take on our program actions .

Wednesday, May 14, 2008

AIR Aplication Work Offline With Sqllite

We can make the AIR application work offline and synch with the database.

We can use sqllite databse for the offline display of data.
sqllite is just like mysql but it would create a *.db file in ur application folder
from where we can access the data.

A sample code for creating and executing the sqllite queries.

on creation complete we create a database contacts.

private function creationComplete():void
connection = new SQLConnection();

var statement = new SQLStatement();

var statement = new SQLStatement();


This is very fast and effective too.


Varun Rathore

Tuesday, February 26, 2008

Set "Loading" screen background color on Flex

Check out the compiler arguments line in the Flex properties and add
-default-background-color #PUTYOURCOLORHERE

Check the complete list compiler aurguments at :-

Monday, February 25, 2008

Granite Data Services

Its free data service provided for the flex users which is alternative to
Life Cycle data service. I have tried remoting service and it runs with good
compatibility without much code change. It also support the data push by the flex.
we can download the binary from www.graniteds.org/ .


Varun Rathore

Tuesday, February 12, 2008

Localising And Resource Bundles in Flex 3.0

Handling resource bundles in flex 3.0 has improved a lot from the previous version.

you just need to add loacale{locale} folder in the source path of the application and have to keep the en_US or ja_JP (which ever language refrence you want to add)

then you will have to make sample.properties file in each of the language refrence folder

in properties file you will have to add
hello=Hello World

the properties which you need to access from the application(here i used hello property)

in the application we will use

we can make the mapping of the resource bundle dynamic with the following code.

add the code in the script of the application


private var locales:Array = [ "en_US" , "fr_FR" ];

private function localeComboBox_initializeHandler(event:Event):void
localeComboBox.selectedIndex =

private function localeComboBox_changeHandler(event:Event):void
// Set the localeChain to either the one-element Array
// [ "en_US" ] or the one-element Array [ "fr_FR" ].
resourceManager.localeChain = [ localeComboBox.selectedItem ];


Change the -locale option to be


Thursday, February 7, 2008

Ant Scripting, Junit ,Flex

If you have any query regarding any of the flex data services , ant targets and Junit test cases
please feel free to contact me .

About Me