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

Browser Web Tools Tutorials

June 4, 2011 Leave a comment

I was going through few blogs to learn jQuery features and come across couple of cool browser developer tools tutorials.

1) This one coves all browsers:

Browser Dev tool tutorial – All Browsers
2) This one is from Google Chrome dev tools section by Paul Irish:
Introduction to The Chrome Developer Tools/

Categories: Browser, HTML, JavaScript

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

ColdFusion – Cross Site Scripting

March 8, 2011 1 comment

I had to fix one site which was sharing server with other sites to be PCI compliant for Cross Site Scripting and DB Injections.

Here are the few things I did to accomplish this.

In Application.cfc, I have added following:

<cfset this.scriptProtect = “all” >

Note: If you are passing object/script or any html  etc tags in form or query variable, this will break your code

Make sure you have following section in your cfusion/lib/neo-security.xml:

<var name=”CrossSiteScriptPatterns”>
<struct type=”coldfusion.server.ConfigMap”><!– this one is for site scripting –>
<var name=”&lt;\s*(object|embed|script|applet|meta|iframe|style|img|form|xss|body|html|head|title|input|layer|br|bgsound|link|xml|frameset|table|div|hr|base|a%20href|a href)”>
</var><!– following is for SQL injections –>
<var name=”;.*(select|insert|update|delete|drop|alter|create)”>

Now all you need to do is find the respective string in your out-put and display the (send user to) appropriate error/ message page

Categories: ColdFusion, Secure