Adding Tooltip to Truncated Datagrid in Flex

Simply set the itemRenderer to mx.controls.Label, as a Label already has truncate and tooltip functionality. And the tooltip will only show when text got truncated.

<mx:DataGridColumn paddingLeft="5" headerRenderer="renderers.ToolTipGridHeaderRenderer"

id="nameCol" itemRenderer="mx.controls.Label" minWidth="110"

headerText="Page URL" dataField="name" sortable="false"/>


Scrollable Flex TabNavigator

This week I have to work on a task to allow for the Flex tab headers to be scrollable when there is not enough room to fit all tabs. As I don’t have much experience in doing Flex programming, it is quite a challenge for me just to think of it.

Thanks to Google & Doug McCune, I have found a solution Doug did back to 2007, and seem like the code still works in Flash Builder 4.6, though with a few tweaks. You can have a look at the post and download source code from here. And the final result looks like:

It has saved me lots of time for finish this task. I am sure it will be useful for someone else too who is working with Flash Builder.

Cloning Objects In Flex

When cloning objects in PHP you simply do:

$newObject = clone $oldObject;

You can do the same thing in Flex:

import mx.utils.ObjectUtil;

var newObject:Object = ObjectUtil.clone(oldObject);

However, this function is only designed to clone data objects. Meaning only objects that holds pure data. It will not work for objects like UIComponent. For the later instance, you will need to create a subclass of the component and implement a clone method instead, or you can try a class written on  ADM Blog for cloning none data objects.

Get Url Query Parameters From Flex

Flex doesn’t support native function to get query parameters from the url and you will have to develop one yourself. I needed this function for one of the tasks I have to complete at work, so I wrote one myself. The code as follows:

import flash.external.ExternalInterface;

public static function getHtmlParameters(queryString:String):String {
var param:String =“”);
if(!param) return ”;

param=param.replace(“\?”, “&”);
var paramArray:Array = param.split(‘&’);
for(var x:int = 0; x<paramArray.length; x++) {
var splitArray:Array = paramArray[x].split(‘=’);

var name:String = splitArray[0];
var value:String = splitArray[1];

if(queryString == name) return value;

return ”;

I think the code is straightforward enough and don’t need more explanations. I hope it can help someone who needed and save your time.

Happy blogging.