Archive for January, 2011

Browser cache issue with Flex HTTPService

January 25, 2011

I struggled to figure this one out, whcih was causing lots of issues in my application. I was using one httpservice to call one URL which will return one xml. This xml in turn forms the dataprovider for one datagrid. The xml is generated based on some selections, but after loading for the first time, after the selection changes, the httpservice was not returning the new xml, in turn it provides the same XML. Hence the datagrid was not getting refreshed. From first view itself I guessed the problem is with caching, since it works well each time I clear the IE cache. Finally the solution is here :

Problem: Repeated HTTPService calls when made from Flex many a times ends up with no external HTTP call. It appears the data is served from cache.

Reason: The Flash Player piggybacks on the browser to make the HTTP call. IE caches the response from the HTTP GET calls and on occurrence of the same URL returns the response from the cache.

Solution: The problem can be solved either at the server side or at the client side.

Server side solution: Set the HTTP headers of the response to avoid returning response from cache.

In HTML: (in the header)

<META HTTP-EQUIV=”Cache-Control” CONTENT=”no-cache”>

In JSP: (before writing to the output stream)response.setHeader(“Cache-Control”,”no-cache”);
response.setDateHeader (“Expires”, 0);

Client side solution: (1) Make HTTP POST call — only HTTP GET calls are served from cache or (2) Make sure the HTTP GET URL is different every time.

(1) Make HTTP POST call – set method=”POST”

(2) Append a unique parameter to the HTTP GET call so that the URL is different every time. A unique time stamp is a good choice.
The following sample code, may do the job:

var params:Object = {};
var noCache:Date = new Date() ;
params.noCache = noCache.getTime().toString() ;

I have named the parameter “noCache”. You can name it anything else you please. The name does not matter. What matters is that the timestamp makes the HTTP GET URL unique.

That’s it guyss.. Enjoy and Happy Coding.. Cheers.


Truncating text in the Flex Label control

January 25, 2011

In Flex, if the text in your label control is exceeding the size of the label, what should you do? One way is to truncate the text inside that and show the complete text in the tooltip when the mouse hovers over the label. This solution is supplied by Flex SDK. You can achieve this using mxml as follows :

<mx:Label text=”The quick brown fox jumped over the lazy dog.”
maxWidth=”200″ />

The same thing can be achieved using actionscript like :

var label:Label = new Label();
label.text = “The quick brown fox jumped over the lazy dog.”;
label.truncateToFit = true;
label.maxWidth = 200;

Pts to be noted here :

  • The text will be truncated to be fit into the container and three dots will be added to the end of the text to denote it have more text to display
  • The width of label shouldn’t be defined in percentage (likelabel.percentWidth=100)

That’s it guys.. Enjoy and Happy Coding.. Cheers..

Removing Spaces from a String in Flex / ActionScript 3

January 10, 2011

If you want to remove any characters from a string using actionscript the following two line code can be used.  The following code removes spaces from a string :

public function removeSpaces(strOriginal:String):String{
var origArr:Array=strOriginal.split(” “);

That’s it guys. Happy Coding 🙂

2010 in review

January 2, 2011

The stats helper monkeys at mulled over how this blog did in 2010, and here’s a high level summary of its overall blog health:

Healthy blog!

The Blog-Health-o-Meter™ reads This blog is doing awesome!.

Crunchy numbers

Featured image

A helper monkey made this abstract painting, inspired by your stats.

A Boeing 747-400 passenger jet can hold 416 passengers. This blog was viewed about 8,900 times in 2010. That’s about 21 full 747s.


In 2010, there were 9 new posts, growing the total archive of this blog to 19 posts.

The busiest day of the year was May 18th with 51 views. The most popular post that day was Flex interview Questions.

Where did they come from?

The top referring sites in 2010 were,,,, and

Some visitors came searching, mostly for flex interview questions, flex interview questions and answers, flex 3 interview questions, ibatis logging, and flex interview question.

Attractions in 2010

These are the posts and pages that got the most views in 2010.


Flex interview Questions December 2008


Logging in Ibatis March 2009
1 comment


Getting Class of an Object in Flex February 2009


Redirecting the Eclipse/Flex Builder Console output to a log file August 2010
1 comment


Like operator in iBatis December 2008

%d bloggers like this: