Archive for the ‘Flex’ Category

Flex HTML ToolTip Component

October 9, 2012 Leave a comment

To enhance the normal tool tip functionality to have html style break/ font weight for a portion of string:

You need to create a action class like this:
package com.philip
import mx.containers.*;
import mx.controls.Text;
import mx.controls.ToolTip;
import mx.core.*;

public class HTMLToolTip extends ToolTip
public function HTMLToolTip()
{    super(); }

override protected function commitProperties():void{
textField.htmlText = text;

to use this set this in your main component, call this function on creationComplete:

import com.*;
private function init():void{
ToolTipManager.toolTipClass = HTMLToolTip;
myBtn.toolTip = “<font color=’#ff00ff’ >this is <b>HTML</b>Tool<strong>Tip.</font>”



The original post has strong tag but that didn’t work for me in Flex 3.5 SDK <b> worked fine


Link to the original post 

Categories: ActionScript, Adobe, Flex

Add Hand Cursor to Flex Tab Navigator

August 25, 2011 5 comments

In Flex Tab Navigator, you can’t have Hand Cursor when you mouse over the tab’s, I had to do little hack to achieve this.

Created two functions and linked them with mouse over and mouse out events.

Say your Tab Navigator’s id is “myTabNav”:

Here are the functions which would do the trick:

private function setHandCursor(event:MouseEvent):void
var classInfo:XML = describeType(;
var cn:String = classInfo.@name.toString();
if(cn == “mx.controls.tabBarClasses::Tab”)
//this will bring the hand cursor

this.myTabNav.buttonMode = true;
this.myTabNav.useHandCursor = true;
private function removeHandCursor(event:MouseEvent):void
var classInfo:XML = describeType(;
var cn:String = classInfo.@name.toString();
if(cn == “mx.controls.tabBarClasses::Tab”)
// this will remove the hand cusror

this.myTabNav.buttonMode = false;
this.myTabNav.useHandCursor = false;


you need to do as above otherwise the hand cursor will either show on complete Tab Navigator

Categories: ActionScript, Adobe, Air, Flex

Read an Image from Local using Flex app

August 4, 2011 Leave a comment

I was working on one small requirement to read an image from local machine and see how it can display if you change size of canvas on fly. I found an article on this and changed the code a bit to make it work as I wanted it to work. you need to create a Flex project to run it in Flash Player 10 or above otherwise it won’t compile.

I have removed the save option in this code but you can change it back by changing visible property of the button.

Thanks to following article Load Or Modify and save local images with flash player 10

Here is the modified code:

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”; layout=”vertical” backgroundGradientColors=”[0xFFFFFF,0xFFFFFF]” backgroundColor=”0xFFFFFF”>

import mx.binding.utils.BindingUtils;
import mx.core.UIComponent;

import flash.utils.ByteArray;
// From
private var loadFileRef:FileReference;

private static const FILE_TYPES:Array = [new FileFilter(“Image Files”, “*.jpg;*.jpeg;*.gif;*.png;*.JPG;*.JPEG;*.GIF;*.PNG”)];
private var THUMB_WIDTH:uint = 240;
private var THUMB_HEIGHT:uint = 180;

private function loadFile():void {
imageView.visible = false;
loadFileRef = new FileReference();
loadFileRef.addEventListener(Event.SELECT, onFileSelect);

private function saveFile():void {
var bitmapData:BitmapData = new BitmapData(THUMB_WIDTH, THUMB_HEIGHT);

var encoder:JPEGEncoder = new JPEGEncoder();
var rawBytes:ByteArray = encoder.encode(bitmapData);

var saveFileRef:FileReference = new FileReference();;

private function onFileSelect(e:Event):void {
loadFileRef.addEventListener(Event.COMPLETE, onFileLoadComplete);

private function onFileLoadComplete(e:Event):void {
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onDataLoadComplete);

loadFileRef = null;

private function onDataLoadComplete(e:Event):void {
var bitmapData:BitmapData = Bitmap(;
imageView.height = Number(heightTxt.text);
imageView.width = Number(widthTxt.text);
var matrix:Matrix = new Matrix();
matrix.scale(Number(widthTxt.text)/bitmapData.width, Number(heightTxt.text)/bitmapData.height);;, matrix, false);, 0, Number(widthTxt.text), Number(heightTxt.text));;
imageView.visible = true;
if (saveButton.visible) saveButton.enabled = true;

<mx:Panel title=”Read image” paddingBottom=”5″ paddingLeft=”5″ paddingRight=”5″ paddingTop=”5″>
<mx:HBox paddingTop=”5″ borderThickness=”1″>
<mx:Label text=”Height” width=”42″/><mx:Label text=”Width” width=”50″/>
<mx:HBox paddingTop=”5″ borderThickness=”1″>
<mx:TextInput id=”heightTxt” width=”40″ text=”180″ restrict=”0-9″ /><mx:TextInput id=”widthTxt” text=”240″ width=”40″ restrict=”0-9″ />
<mx:Button label=”Load image” click=”loadFile()”/>
<mx:Button label=”Save image” visible=”false” click=”saveFile()” id=”saveButton” enabled=”false”/>
<mx:Canvas id=”imageView” width=”240″ height=”180″ visible=”false” borderThickness=”1″ borderColor=”#CCCCCC” borderStyle=”solid”/>

Categories: ActionScript, Adobe, Flex

Setting up Flex Project for Flash Player 10 and above

August 4, 2011 Leave a comment

I had a requirement in my new Flex project to use flash player 10.0 or up when using SDK 3.5

I found few tips from one article (but it was based on Flash Player 10 beta).

Here are the modified steps I took to sort the issue.

1) – Modify FLEX_SDK/frameworks/flex-config.xml.
Edit , replacing 9.0.124 with 10.0.0:
2) Create new Flex Project
2) Right click on your project in Flex Builder 3 and opt for properties
click on Flex Compiler and make sure Required Flash Player version has

The above steps should let you create your Flex app for Flash Player 10.0 and above

Categories: Flex, Flex SDK

How to set width of close button icon (Flex)

July 19, 2011 Leave a comment

Here is how you can set close button icon width and height of the TitleWindow:

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:TitleWindow xmlns:mx=”; layout=”absolute” width=”400″ height=”300″

import mx.core.mx_internal;

private function init():void
use namespace mx_internal;
mx_internal::closeButton.buttonMode = true;
closeButton.$width  = 14; //Change the button width to 14 pixels
closeButton.$height = 14; //Change the button height to 14 pixels


border-color: #FFFFFF;
corner-radius: 10;
closeButtonUpSkin=Embed(source=”/com/test/skin/assets.swf”, symbol=”ButtonUp”);
closeButtonDownSkin=Embed(source=”/com/test/skin/assets.swf”, symbol=”ButtonUp”);
closeButtonOverSkin=Embed(source=”/com/test/skin/assets.swf”, symbol=”ButtonDown”);



Categories: ActionScript, Air, Flex

View Generated ActionScript of Flex Project

March 13, 2011 1 comment

I found it very interesting to view how and what Flex Compiler does when it generates a SWF file of your project.

To see the ActionScript created by your complier, you can add a compiler argument in Flash Builder .

Navigate to Project > Properties > Flex Compiler > Additional compiler arguments,

and add -keep-generated-actionscript to the end of the existing arguments .

A folder named bin-debug/generated will be created automatically in your project, and many ActionScript files will be placed there .

Your application files will be in the form Name-generated .as .

Don’t forget to remove the compiler argument when you’ve finished exploring.

Categories: ActionScript, Flex

Flex- TitleWindow Close Button Hand Cursor

March 7, 2011 Leave a comment

I had requirement to bring the hand pointer on title window (Flex) close button when I am using an image to show the close button and here is the code (function) you need to write and call it on creationComplete Event.

private function init():void

mx_internal::closeButton.buttonMode = true;

Categories: ActionScript, Adobe, Flex

Flash Builder4 – Helpful links

August 21, 2010 Leave a comment

Flash Builder 4 – Helpful Links (Good articles)

Installing subversion plug-in (Link)

Difference between Flex 3 and Flex 4 By Joan Lafferty (Link)

Whats new in Flex 4 By Deepa Subramaniam (Link)

Whats new in Flash Builder 4 by Andrew Shorten (Link)

Categories: Adobe, Flex

Extending CFC – DAO

August 17, 2010 2 comments

I came across very strange behaviour of extending CFC to another CFC for my DTO’s, which I was using to send data back to my Flex application using AMF.

My Main parent CFC had 3 properties.
I created new CFC and extended to the above CFC and added 3 more properties.
It works fine with in ColdFusion, but when I used it to return to my Flex application with type binding to my ActionScript DTO.
This wasn’t sending the parents properties to my Flex application.
To fix this I had to add all properties in my extended CFC (Child one).

Has any one come across the similar scenario?

How to Improve Flex data transfer from CF?

August 15, 2010 Leave a comment

I found this article and realised that transferring data from CF (CFC objects) to Flex application using this way will reduce the packet size and improve the performance.

You don’t need to create an object of the CFC type you want to send data across in your array, but what you need to do is take following steps and you can improve your application’s performance:

Following code is how I used to send data across to my Flex App:

<cfloop query=”myQuery”>


local.result = createObject(“component”,”com.philip.myproj.myobj”);



arrayAppend(local.results, local.result);



The above method is how most of the developers use and it works fine only downside is this passes the complete object with all setter’s and getter’s and makes it bulky.

The following method is very light weight to pass the objects around and its documented in here: Writing the ColdFusion CFCs

you just need to change the object creation step with creating a simple Struct and you need to add an extra line to declare its a type of following CFC Value object likt this:

local.result[“__type__”] =”com.philip.myproj.myobj”;

Here is how you write the code using above type declaration:

<cfloop query=”myQuery”>


local.result = structNew();

local.result[“__type__”] = “com.philip.myproj.myobj”;

local.result[“prop1”] = myQuery.val1;

local.result[“prop2”] = myQuery.val2;

arrayAppend(local.results, local.result);



And Flax / Flash is sharp enough to pick this up and automatically link with ActionsScript VO class and you will get typed data.

Categories: Adobe, ColdFusion, Flex